-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #179 from JLLeitschuh/chore/betterErrorAndExceptio…
…nHandling Improves unexpected throwable handling
- Loading branch information
Showing
7 changed files
with
92 additions
and
66 deletions.
There are no files selected for viewing
19 changes: 0 additions & 19 deletions
19
core/src/main/java/edu/wpi/grip/core/events/FatalErrorEvent.java
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
core/src/main/java/edu/wpi/grip/core/events/UnexpectedThrowableEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package edu.wpi.grip.core.events; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
/** | ||
* Event should be thrown when Unexpected Throwable ends up in an {@link Thread#uncaughtExceptionHandler}. | ||
*/ | ||
public final class UnexpectedThrowableEvent { | ||
private final Throwable throwable; | ||
private final boolean fatal; | ||
private final String message; | ||
|
||
/** | ||
* @param throwable The throwable that was caught. | ||
* @param message Any additional information that should be displayed to the user. Nullable. | ||
* @param fatal True if this cause the application to quit forcibly. | ||
* If the throwable is an {@link Error} than this is automatically true. Defaults to false. | ||
*/ | ||
public UnexpectedThrowableEvent(Throwable throwable, String message, boolean fatal) { | ||
this.throwable = checkNotNull(throwable, "Throwable can not be null"); | ||
this.message = checkNotNull(message, "Message can not be null"); | ||
this.fatal = (throwable instanceof Error) || fatal; | ||
} | ||
|
||
public UnexpectedThrowableEvent(Throwable throwable, String message) { | ||
this(throwable, message, false); | ||
} | ||
|
||
|
||
public Throwable getThrowable() { | ||
return throwable; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
/** | ||
* @return True if this should cause the program to shutdown after it is handled | ||
*/ | ||
public boolean isFatal() { | ||
return fatal; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters