Properly Handle Nested Dispatches #19
@ -94,14 +94,14 @@ public final class EventBus {
|
|||||||
try {
|
try {
|
||||||
handlers.next().execute(event);
|
handlers.next().execute(event);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
if (event instanceof DeadEvent || event instanceof ExceptionEvent)
|
if (e.getCause() instanceof Error)
|
||||||
|
|
||||||
// Warn about system event not being handled
|
|
||||||
logger.log(Level.WARNING, event + " not handled due to exception", e);
|
|
||||||
else if (e.getCause() instanceof Error)
|
|
||||||
|
|
||||||
// Transparently pass error to the caller
|
// Transparently pass error to the caller
|
||||||
throw (Error) e.getCause();
|
throw (Error) e.getCause();
|
||||||
|
else if (event instanceof DeadEvent || event instanceof ExceptionEvent)
|
||||||
|
|
||||||
|
// Warn about system event not being handled
|
||||||
|
logger.log(Level.WARNING, event + " not handled due to exception", e);
|
||||||
else
|
else
|
||||||
|
|
||||||
// Dispatch exception event
|
// Dispatch exception event
|
||||||
|
Loading…
Reference in New Issue
Block a user