Package io.activej.common.exception
Interface FatalErrorHandler
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A callback for any fatal (unchecked) exceptions
Also contains various default handlers
-
Method Summary
Modifier and TypeMethodDescriptiondefault FatalErrorHandlerandThen(FatalErrorHandler nextHandler) Combines handlers by chaining the next handler after the current onestatic FatalErrorHandlerReturns a thread fatal error handler.static Exceptiondefault voidCalled when an unchecked exception is caught during execution of some taskvoidCalled when an unchecked exception is caught during execution of some taskstatic voidhandleError(FatalErrorHandler fatalErrorHandler, Throwable e, @Nullable Object context) Uses a given fatal error handler to handle a receivedThrowablestatic voidUses current thread's fatal error handler to handle a receivedThrowablestatic voidhandleError(Throwable e, @Nullable Object context) Uses current thread's fatal error handler to handle a receivedThrowablestatic voidSets a global fatal error handler.static voidsetThreadFatalErrorHandler(@Nullable FatalErrorHandler handler) Sets a fatal error handler for a current thread
-
Method Details
-
handle
Called when an unchecked exception is caught during execution of some task- Parameters:
e- the caught exceptioncontext- the context in which exception was caught in, possiblynull
-
handle
Called when an unchecked exception is caught during execution of some task- Parameters:
e- the caught exception- See Also:
-
andThen
Combines handlers by chaining the next handler after the current one -
setThreadFatalErrorHandler
Sets a fatal error handler for a current thread- Parameters:
handler- a global fatal error handler
-
setGlobalFatalErrorHandler
Sets a global fatal error handler. This handler will be used if no other handler was set for a handling thread usingsetThreadFatalErrorHandler(FatalErrorHandler)- Parameters:
handler- a global fatal error handler
-
getCurrent
Returns a thread fatal error handler. If no thread fatal error handler was set usingsetThreadFatalErrorHandler(FatalErrorHandler), a global fatal error handler will be returned- Returns:
- a thread fatal error handler or a global fatal error handler if thread's handler was not set
-
handleError
static void handleError(FatalErrorHandler fatalErrorHandler, Throwable e, @Nullable @Nullable Object context) Uses a given fatal error handler to handle a receivedThrowableIf an error is a checked exception, no handling will be performed
An optional context may be passed for debug purposes
- Parameters:
fatalErrorHandler- a fatal error handlere- an error to be handledcontext- an optional context that provides additional debug information- See Also:
-
handleError
Uses current thread's fatal error handler to handle a receivedThrowableIf no error handler is set for the current thread, uses a global fatal error handler
If an error is a checked exception, no handling will be performed
An optional context may be passed for debug purposes
- Parameters:
e- an error to be handledcontext- an optional context that provides additional debug information- See Also:
-
handleError
Uses current thread's fatal error handler to handle a receivedThrowable- See Also:
-
getExceptionOrThrowError
-