public class RecordingListenerInvocationErrorHandler extends Object implements ListenerInvocationErrorHandler
ListenerInvocationErrorHandler
that in itself also implements
ListenerInvocationErrorHandler
. Any Exception encountered will be stored, after which the rest of the error
handling will be handed off to the wrapped ListenerInvocationErrorHandler.Constructor and Description |
---|
RecordingListenerInvocationErrorHandler(ListenerInvocationErrorHandler listenerInvocationErrorHandler)
Create a new instance of this class, wrapping another
ListenerInvocationErrorHandler . |
Modifier and Type | Method and Description |
---|---|
void |
failOnErrorInPreparation(boolean failOnErrorInPreparation)
Configure whether this error handler should fail on errors in the preparation phase.
|
Optional<Exception> |
getException()
Return the last encountered Exception after the startRecording method has been invoked, or an empty Optional of
no Exception occurred.
|
void |
onError(Exception exception,
EventMessage<?> event,
EventMessageHandler eventHandler)
Invoked after given
eventListener failed to handle given event . |
void |
setListenerInvocationErrorHandler(ListenerInvocationErrorHandler listenerInvocationErrorHandler)
Sets a new wrapped
ListenerInvocationErrorHandler . |
void |
startRecording()
Start recording by clearing any current
Exception . |
public RecordingListenerInvocationErrorHandler(ListenerInvocationErrorHandler listenerInvocationErrorHandler)
ListenerInvocationErrorHandler
.listenerInvocationErrorHandler
- The ListenerInvocationErrorHandler
to invoke for the error
handling, cannot be null.public void onError(@Nonnull Exception exception, @Nonnull EventMessage<?> event, @Nonnull EventMessageHandler eventHandler) throws Exception
ListenerInvocationErrorHandler
eventListener
failed to handle given event
. Implementations have a
choice of options for how to continue:
EventMessageHandler.handle(EventMessage)
on the eventListener once or multiple times.onError
in interface ListenerInvocationErrorHandler
exception
- The exception thrown by the given eventListenerevent
- The event that triggered the exceptioneventHandler
- The listener that failed to handle given eventException
- To stop further handling of the eventpublic void startRecording()
Exception
.public void setListenerInvocationErrorHandler(ListenerInvocationErrorHandler listenerInvocationErrorHandler)
ListenerInvocationErrorHandler
.listenerInvocationErrorHandler
- The ListenerInvocationErrorHandler
to invoke for the error
handling, cannot be null.public Optional<Exception> getException()
public void failOnErrorInPreparation(boolean failOnErrorInPreparation)
started
yet.
When set to true
will rethrow the exception, regardless of the configured
ListenerInvocationErrorHandler
. Defaults to true
.
failOnErrorInPreparation
- A boolean
dictating whether to rethrow if this recorder is not started.Copyright © 2010–2024. All rights reserved.