public class ChainedExceptionHandler extends Object implements ExceptionHandler
Handlers are evaluated left to right. If a handler throws, the failure is logged at error level and the next handler is called.
Construction prunes instances of IgnoresEverything and unwraps any
ThreadLocalisedExceptionHandler.
The chain is immutable and has no internal synchronisation. It is thread-safe provided the supplied handlers are thread-safe.
ExceptionHandler chain = new ChainedExceptionHandler(
Slf4jExceptionHandler.ERROR,
new RecordingExceptionHandler(LogLevel.ERROR, map, true)
);
| Constructor and Description |
|---|
ChainedExceptionHandler(ExceptionHandler... chain)
Creates a new chain of handlers.
|
| Modifier and Type | Method and Description |
|---|---|
@NotNull ExceptionHandler[] |
chain()
Returns the handlers in evaluation order.
|
void |
on(@NotNull Class<?> clazz,
@Nullable String message,
@Nullable Throwable thrown)
Passes the event to each handler.
|
void |
on(@NotNull org.slf4j.Logger logger,
@Nullable String message,
Throwable thrown)
Passes the event to each handler.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdefaultHandler, ignoresEverything, isEnabled, on, on, onpublic ChainedExceptionHandler(@NotNull
ExceptionHandler... chain)
chain - the handlers to evaluate from left to rightNullPointerException - if chain or any element is nullpublic void on(@NotNull
@NotNull Class<?> clazz,
@Nullable
@Nullable String message,
@Nullable
@Nullable Throwable thrown)
on in interface ExceptionHandlerclazz - the originating class, not nullmessage - an optional messagethrown - an optional throwableNullPointerException - if clazz is nullpublic void on(@NotNull
@NotNull org.slf4j.Logger logger,
@Nullable
@Nullable String message,
Throwable thrown)
on in interface ExceptionHandlerlogger - the logger to use, not nullmessage - an optional messagethrown - an optional throwableNullPointerException - if logger is null@NotNull public @NotNull ExceptionHandler[] chain()
Copyright © 2026 Chronicle Software Ltd. All rights reserved.