feat?: Don't swallow exceptions in EventSystem#invoke
We currently swallow all exceptions thrown during event handling in `EventSystemImpl#invoke` and just log the error.
Not catching the error will hand it further up, leading to a game crash eventually (which is probably the better option given that we're talking about arbitrary exceptions here).
@@ -359,7 +359,11 @@ public boolean isValidFor(EntityRef entity) {
@Override
public void invoke(EntityRef entity, Event event) {
- try {
+ // 2021-05-28 We used to catch all kinds of exceptions here that occurred during event invokation. As most
+ // module logic depends on event handling, this basically covered ALL exceptions thrown in any system.
+ //
+ // There might be specific events that can be safely handled here. In that case, we should add the try-catch
+ // back in for the most specific exception type as possible.
Object[] params = new Object[2 + componentParams.size()];
params[0] = event;
params[1] = entity;
@@ -378,9 +382,6 @@ public void invoke(EntityRef entity, Event event) {
PerformanceMonitor.endActivity();
}
}
- } catch (Exception ex) {
- logger.error("Failed to invoke event", ex);
- }
}
@Override
