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() |
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, wait
ignoresEverything, on, on, on
public ThreadLocalisedExceptionHandler(ExceptionHandler handler)
public void on(@NotNull @NotNull Class<?> clazz, @Nullable @Nullable String message, @Nullable @Nullable Throwable thrown)
ExceptionHandler
on
in interface ExceptionHandler
clazz
- the class where the error occurred. Must not be null.message
- a custom message detailing the error, or an empty string.thrown
- the throwable instance representing the error, or null if there was no exception.public void on(@NotNull @NotNull org.slf4j.Logger logger, @Nullable @Nullable String message, Throwable thrown)
ExceptionHandler
on
in interface ExceptionHandler
logger
- 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()
defaultHandler
in interface ExceptionHandler
public 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)
ExceptionHandler
isEnabled
in interface ExceptionHandler
aClass
- the class to check if the exception handler is enabled for. Must not be null.Copyright © 2023. All rights reserved.