Package io.activej.common.exception
Class FatalErrorHandlers
java.lang.Object
io.activej.common.exception.FatalErrorHandlers
Utility methods that allow to handle fatal errors using thread-specific handlers
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ExceptiongetExceptionOrThrowError(@NotNull Throwable t) static @NotNull FatalErrorHandlerReturns a thread fatal error handler.static voidhandleError(@NotNull FatalErrorHandler fatalErrorHandler, @NotNull Throwable e, @Nullable Object context) Uses a given fatal error handler to handle a receivedThrowablestatic voidhandleError(@NotNull Throwable e) Uses current thread's fatal error handler to handle a receivedThrowablestatic voidhandleError(@NotNull Throwable e, @Nullable Object context) Uses current thread's fatal error handler to handle a receivedThrowablestatic voidsetGlobalFatalErrorHandler(@NotNull FatalErrorHandler handler) Sets a global fatal error handler.static voidsetThreadFatalErrorHandler(@Nullable FatalErrorHandler handler) Sets a fatal error handler for a current thread
-
Constructor Details
-
FatalErrorHandlers
public FatalErrorHandlers()
-
-
Method Details
-
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
-
getFatalErrorHandler
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
public static void handleError(@NotNull @NotNull FatalErrorHandler fatalErrorHandler, @NotNull @NotNull 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
-