Package org.threadly.util
Interface ExceptionHandler
-
- All Superinterfaces:
java.util.function.Consumer<java.lang.Throwable>
public interface ExceptionHandler extends java.util.function.Consumer<java.lang.Throwable>
Interface for implementation to handle exceptions which occur. This is similar toThread.UncaughtExceptionHandler
, except that exceptions provided to this interface are handled on the same thread that threw the exception, and the thread that threw it likely WONT die.- Since:
- 4.3.0 (since 2.4.0 as ExceptionHandlerInterface)
-
-
Field Summary
Fields Modifier and Type Field Description static ExceptionHandler
IGNORE_HANDLER
DefaultExceptionHandler
implementation which will swallow the exception with no action.static ExceptionHandler
PRINT_STACKTRACE_HANDLER
DefaultExceptionHandler
implementation which will invokeThrowable.printStackTrace()
.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
accept(java.lang.Throwable thrown)
void
handleException(java.lang.Throwable thrown)
An exception was thrown on this thread, and is now being provided to this handler to handle it (possibly just to simply log it occurred).
-
-
-
Field Detail
-
PRINT_STACKTRACE_HANDLER
static final ExceptionHandler PRINT_STACKTRACE_HANDLER
DefaultExceptionHandler
implementation which will invokeThrowable.printStackTrace()
.
-
IGNORE_HANDLER
static final ExceptionHandler IGNORE_HANDLER
DefaultExceptionHandler
implementation which will swallow the exception with no action.
-
-
Method Detail
-
handleException
void handleException(java.lang.Throwable thrown)
An exception was thrown on this thread, and is now being provided to this handler to handle it (possibly just to simply log it occurred).- Parameters:
thrown
- Throwable that was thrown, and caught
-
accept
default void accept(java.lang.Throwable thrown)
- Specified by:
accept
in interfacejava.util.function.Consumer<java.lang.Throwable>
-
-