public class ChainedExceptionHandler extends Object implements ExceptionHandler
ExceptionHandler that chains multiple ExceptionHandler objects
to be invoked in sequence.
This class encapsulates an ordered collection of ExceptionHandler instances and calls
each of them in turn when an exception occurs. If an ExceptionHandler in the chain
itself throws an exception, this exception will be logged and the next ExceptionHandler
in the chain will be called.
When constructing a new instance, all ExceptionHandlers that are instances of
IgnoresEverything will be filtered out. Furthermore, any ExceptionHandler that
is an instance of ThreadLocalisedExceptionHandler will be unwrapped to its underlying
ExceptionHandler.
| Constructor and Description |
|---|
ChainedExceptionHandler(ExceptionHandler... chain) |
| Modifier and Type | Method and Description |
|---|---|
@NotNull ExceptionHandler[] |
chain() |
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdefaultHandler, ignoresEverything, isEnabled, on, on, onpublic ChainedExceptionHandler(@NotNull
ExceptionHandler... chain)
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.@NotNull public @NotNull ExceptionHandler[] chain()
Copyright © 2024. All rights reserved.