public class ThreadLocalisedExceptionHandler extends Object implements ExceptionHandler
The default ExceptionHandler can be set using the defaultHandler method, and is initially passed to the constructor when creating a new instance of this class.
| Constructor and Description |
|---|
ThreadLocalisedExceptionHandler(ExceptionHandler handler) |
| Modifier and Type | Method and Description |
|---|---|
ExceptionHandler |
defaultHandler()
Retrieves the default underlying exception handler.
|
ThreadLocalisedExceptionHandler |
defaultHandler(ExceptionHandler defaultHandler) |
boolean |
isEnabled(@NotNull Class<?> aClass)
Checks if the exception handler is enabled for the given class.
|
void |
on(@NotNull Class<?> clazz,
@Nullable String message,
@Nullable Throwable thrown)
The default method to call when an exception occurs.
|
void |
on(@NotNull org.slf4j.Logger logger,
@Nullable String message,
Throwable thrown)
Handles an exception occurred with a specific logger, message and throwable.
|
void |
resetThreadLocalHandler() |
ExceptionHandler |
threadLocalHandler() |
ThreadLocalisedExceptionHandler |
threadLocalHandler(ExceptionHandler handler) |
static ExceptionHandler |
unwrap(ExceptionHandler eh) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitignoresEverything, on, on, onpublic ThreadLocalisedExceptionHandler(ExceptionHandler handler)
public void on(@NotNull
@NotNull Class<?> clazz,
@Nullable
@Nullable String message,
@Nullable
@Nullable Throwable thrown)
ExceptionHandleron in interface ExceptionHandlerclazz - the class where the exception occurred. Must not be null.message - a custom message providing additional information about the exception, or an empty string if not available.thrown - the exception that needs to be handled, or null if there is no exception.public void on(@NotNull
@NotNull org.slf4j.Logger logger,
@Nullable
@Nullable String message,
Throwable thrown)
ExceptionHandleron in interface ExceptionHandlerlogger - the logger instance to log the error. Must not be null.message - a custom message detailing the error, or null.thrown - the throwable instance representing the error, or null.public ExceptionHandler defaultHandler()
ExceptionHandlerdefaultHandler in interface ExceptionHandlerpublic static ExceptionHandler unwrap(ExceptionHandler eh)
public ThreadLocalisedExceptionHandler defaultHandler(ExceptionHandler defaultHandler)
public ExceptionHandler threadLocalHandler()
public ThreadLocalisedExceptionHandler threadLocalHandler(ExceptionHandler handler)
public void resetThreadLocalHandler()
public boolean isEnabled(@NotNull
@NotNull Class<?> aClass)
ExceptionHandlerisEnabled in interface ExceptionHandleraClass - the class to check if the exception handler is enabled for. Must not be null.Copyright © 2024. All rights reserved.