Package org.axonframework.test.saga
Class RecordingListenerInvocationErrorHandler
java.lang.Object
org.axonframework.test.saga.RecordingListenerInvocationErrorHandler
- All Implemented Interfaces:
org.axonframework.eventhandling.ListenerInvocationErrorHandler
public class RecordingListenerInvocationErrorHandler
extends Object
implements org.axonframework.eventhandling.ListenerInvocationErrorHandler
A wrapper around a
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.- Since:
- 4.6.0
- Author:
- Christian Vermorken
-
Constructor Summary
ConstructorsConstructorDescriptionRecordingListenerInvocationErrorHandler(org.axonframework.eventhandling.ListenerInvocationErrorHandler listenerInvocationErrorHandler) Create a new instance of this class, wrapping anotherListenerInvocationErrorHandler. -
Method Summary
Modifier and TypeMethodDescriptionvoidfailOnErrorInPreparation(boolean failOnErrorInPreparation) Configure whether this error handler should fail on errors in the preparation phase.Return the last encountered Exception after the startRecording method has been invoked, or an empty Optional of no Exception occurred.voidonError(Exception exception, org.axonframework.eventhandling.EventMessage<?> event, org.axonframework.eventhandling.EventMessageHandler eventHandler) voidsetListenerInvocationErrorHandler(org.axonframework.eventhandling.ListenerInvocationErrorHandler listenerInvocationErrorHandler) Sets a new wrappedListenerInvocationErrorHandler.voidStart recording by clearing any currentException.
-
Constructor Details
-
RecordingListenerInvocationErrorHandler
public RecordingListenerInvocationErrorHandler(org.axonframework.eventhandling.ListenerInvocationErrorHandler listenerInvocationErrorHandler) Create a new instance of this class, wrapping anotherListenerInvocationErrorHandler.- Parameters:
listenerInvocationErrorHandler- TheListenerInvocationErrorHandlerto invoke for the error handling, cannot be null.
-
-
Method Details
-
onError
public void onError(@Nonnull Exception exception, @Nonnull org.axonframework.eventhandling.EventMessage<?> event, @Nonnull org.axonframework.eventhandling.EventMessageHandler eventHandler) throws Exception - Specified by:
onErrorin interfaceorg.axonframework.eventhandling.ListenerInvocationErrorHandler- Throws:
Exception
-
startRecording
public void startRecording()Start recording by clearing any currentException. -
setListenerInvocationErrorHandler
public void setListenerInvocationErrorHandler(org.axonframework.eventhandling.ListenerInvocationErrorHandler listenerInvocationErrorHandler) Sets a new wrappedListenerInvocationErrorHandler.- Parameters:
listenerInvocationErrorHandler- TheListenerInvocationErrorHandlerto invoke for the error handling, cannot be null.
-
getException
Return the last encountered Exception after the startRecording method has been invoked, or an empty Optional of no Exception occurred.- Returns:
- an Optional of the last encountered Exception
-
failOnErrorInPreparation
public void failOnErrorInPreparation(boolean failOnErrorInPreparation) Configure whether this error handler should fail on errors in the preparation phase. This means recording has notstartedyet.When set to
truewill rethrow the exception, regardless of the configuredListenerInvocationErrorHandler. Defaults totrue.- Parameters:
failOnErrorInPreparation- Abooleandictating whether to rethrow if this recorder is not started.
-