Add exception handling to event bus, and a flag to indicate a unhandled exception to the Event base class
This commit is contained in:
parent
8976d8fb7f
commit
6fdfa52e1a
2 changed files with 10 additions and 0 deletions
|
@ -3,6 +3,13 @@ package dev.zontreck.ariaslib.events;
|
|||
|
||||
public abstract class Event {
|
||||
private boolean isCancelled=false;
|
||||
/**
|
||||
* True is the event ended early due to a unhandled exception.
|
||||
*
|
||||
* The event bus will continue processing.
|
||||
*/
|
||||
public boolean exceptionThrown = false;
|
||||
|
||||
|
||||
public Event()
|
||||
{
|
||||
|
|
|
@ -80,6 +80,9 @@ public class EventBus
|
|||
eventContainer.function.invoke(eventContainer.containingClass, event);
|
||||
} catch (IllegalAccessException|IllegalArgumentException|InvocationTargetException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e)
|
||||
{
|
||||
event.exceptionThrown=true;
|
||||
}
|
||||
|
||||
cancelled=event.isCancelled();
|
||||
|
|
Loading…
Reference in a new issue