Improved error logging in event bus

This commit is contained in:
Vankka 2022-03-28 17:25:23 +03:00
parent ff63376550
commit 29e01878b2
No known key found for this signature in database
GPG Key ID: 6E50CB7A29B96AD0

View File

@ -206,9 +206,15 @@ public class EventBusImpl implements EventBus {
Object listener = eventListener.listener();
eventListener.method().invoke(listener, event);
} catch (IllegalAccessException e) {
discordSRV.logger().error("Failed to access listener method: " + eventListener.methodName(), e);
discordSRV.logger().error("Failed to access listener method: " + eventListener.methodName() + " in " + eventListener.className(), e);
} catch (InvocationTargetException e) {
discordSRV.logger().error("Failed to pass " + event.getClass().getSimpleName() + " to " + eventListener, e.getCause());
String eventClassName = eventClass.getName();
Throwable cause = e.getCause();
if (eventListener.className().startsWith("com.discordsrv")) {
discordSRV.logger().error("Failed to pass " + eventClassName + " to " + eventListener, cause);
} else {
e.getCause().printStackTrace();
}
}
long timeTaken = System.currentTimeMillis() - startTime;
logger.trace(eventListener + " took " + timeTaken + "ms to execute");