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

    Constructors
    Constructor
    Description
    RecordingListenerInvocationErrorHandler(org.axonframework.eventhandling.ListenerInvocationErrorHandler listenerInvocationErrorHandler)
    Create a new instance of this class, wrapping another ListenerInvocationErrorHandler.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    failOnErrorInPreparation(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.
    void
    onError(Exception exception, org.axonframework.eventhandling.EventMessage<?> event, org.axonframework.eventhandling.EventMessageHandler eventHandler)
     
    void
    setListenerInvocationErrorHandler(org.axonframework.eventhandling.ListenerInvocationErrorHandler listenerInvocationErrorHandler)
    Sets a new wrapped ListenerInvocationErrorHandler.
    void
    Start recording by clearing any current Exception.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RecordingListenerInvocationErrorHandler

      public RecordingListenerInvocationErrorHandler(org.axonframework.eventhandling.ListenerInvocationErrorHandler listenerInvocationErrorHandler)
      Create a new instance of this class, wrapping another ListenerInvocationErrorHandler.
      Parameters:
      listenerInvocationErrorHandler - The ListenerInvocationErrorHandler to 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:
      onError in interface org.axonframework.eventhandling.ListenerInvocationErrorHandler
      Throws:
      Exception
    • startRecording

      public void startRecording()
      Start recording by clearing any current Exception.
    • setListenerInvocationErrorHandler

      public void setListenerInvocationErrorHandler(org.axonframework.eventhandling.ListenerInvocationErrorHandler listenerInvocationErrorHandler)
      Sets a new wrapped ListenerInvocationErrorHandler.
      Parameters:
      listenerInvocationErrorHandler - The ListenerInvocationErrorHandler to invoke for the error handling, cannot be null.
    • getException

      public Optional<Exception> 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 not started yet.

      When set to true will rethrow the exception, regardless of the configured ListenerInvocationErrorHandler. Defaults to true.

      Parameters:
      failOnErrorInPreparation - A boolean dictating whether to rethrow if this recorder is not started.