refactor: catch Throwable on some things

mainly the ListenerManagerPlugin because it also handles packets so we don't want the bot to disconnect even on fatal error
This commit is contained in:
ChomeNS
2025-05-25 13:12:26 +07:00
parent a368cc6f13
commit 9afbdc26b3
2 changed files with 7 additions and 7 deletions

View File

@@ -24,14 +24,14 @@ public class ListenerManagerPlugin {
for (final Listener listener : listeners) {
try {
consumer.accept(listener);
} catch (final Exception e) {
} catch (final Throwable throwable) {
bot.logger.error(
Component.translatable(
"Caught exception while trying to dispatch an event to %s!",
"Caught an error while trying to dispatch an event to %s!",
Component.text(listener.getClass().getSimpleName())
)
);
bot.logger.error(e);
bot.logger.error(throwable);
}
}
}
@@ -44,14 +44,14 @@ public class ListenerManagerPlugin {
final Boolean result = function.apply(listener);
if (result != null && !result) break;
} catch (final Exception e) {
} catch (final Throwable throwable) {
bot.logger.error(
Component.translatable(
"Caught exception while trying to dispatch an event with a returning boolean to %s!",
"Caught an error while trying to dispatch an event with a returning boolean to %s!",
Component.text(listener.getClass().getSimpleName())
)
);
bot.logger.error(e);
bot.logger.error(throwable);
}
}
}

View File

@@ -249,7 +249,7 @@ public class ComponentUtilities {
result.add(Component.text(remaining));
}
} catch (final Exception e) {
} catch (final Throwable throwable) {
result.clear();
result.add(Component.text(format));
}