Package edu.wpi.grip.core.events
Class UnexpectedThrowableEvent
- java.lang.Object
-
- edu.wpi.grip.core.events.UnexpectedThrowableEvent
-
- All Implemented Interfaces:
LoggableEvent
public final class UnexpectedThrowableEvent extends java.lang.Object implements LoggableEvent
Event should be thrown when Unexpected Throwable ends up in anThread.uncaughtExceptionHandler
. This event may potentially only be handled once if the exception is deemed fatal.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
UnexpectedThrowableEvent.UnexpectedThrowableEventHandler
A functional interface allowing for UnexpectedThrowableEvents to be handled safely.
-
Constructor Summary
Constructors Constructor Description UnexpectedThrowableEvent(java.lang.Throwable throwable, java.lang.String message)
UnexpectedThrowableEvent(java.lang.Throwable throwable, java.lang.String message, boolean fatal)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
handleSafely(UnexpectedThrowableEvent.UnexpectedThrowableEventHandler handler)
Handles the exception, this method can only be called once if the event is fatal.boolean
isFatal()
void
shutdownIfFatal()
This method will not return if the event is fatal.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.wpi.grip.core.events.LoggableEvent
asLoggableString, logLevel
-
-
-
-
Constructor Detail
-
UnexpectedThrowableEvent
public UnexpectedThrowableEvent(java.lang.Throwable throwable, java.lang.String message, boolean fatal)
- Parameters:
throwable
- The throwable that was caught.message
- Any additional information that should be displayed to the user. Nullable.fatal
- True if this cause the application to quit forcibly. If the throwable is anError
than this is automatically true. Defaults to false.
-
UnexpectedThrowableEvent
public UnexpectedThrowableEvent(java.lang.Throwable throwable, java.lang.String message)
-
-
Method Detail
-
handleSafely
public void handleSafely(UnexpectedThrowableEvent.UnexpectedThrowableEventHandler handler)
Handles the exception, this method can only be called once if the event is fatal. If the event is fatal then this method will never return.- Parameters:
handler
- Handles the exception but in the safest way possible. Will not be run if throwable is an interrupted exception.
-
shutdownIfFatal
public void shutdownIfFatal()
This method will not return if the event is fatal.
-
isFatal
public boolean isFatal()
- Returns:
- True if this should cause the program to shutdown after it is handled.
-
-