Class CommandExecutionException

All Implemented Interfaces:
Serializable

public class CommandExecutionException extends HandlerExecutionException
Indicates that an exception has occurred while handling a command. Typically, this class is used to wrap checked exceptions that have been thrown from a Command Handler while processing an incoming command.

By default, a stack trace is not generated for this exception. However, the stack trace creation can be enforced explicitly via the constructor accepting the writableStackTrace parameter.

Since:
1.3.0
Author:
Allard Buijze
See Also:
  • Constructor Details

    • CommandExecutionException

      public CommandExecutionException(String message, Throwable cause)
      Initializes the exception with given message and cause.
      Parameters:
      message - The message describing the exception.
      cause - The cause of the exception.
    • CommandExecutionException

      public CommandExecutionException(String message, Throwable cause, @Nullable Object details)
      Initializes the exception with given message, cause and an object providing application-specific details.
      Parameters:
      message - the message describing the exception
      cause - the cause of the exception
      details - an object providing more error details (might be null)
    • CommandExecutionException

      public CommandExecutionException(String message, Throwable cause, @Nullable Object details, boolean writableStackTrace)
      Initializes the exception with given message, cause, an object providing application-specific details, and writableStackTrace
      Parameters:
      message - the message describing the exception
      cause - the cause of the exception
      details - an object providing more error details (might be null)
      writableStackTrace - whether the stack trace should be generated (true) or not (false)
    • CommandExecutionException

      @Internal public CommandExecutionException(String message, Throwable cause, @Nullable Object details, @Nullable Converter converter, boolean writableStackTrace)
      Initializes the exception with given message, cause, an object providing application-specific details, a converter, and writableStackTrace.

      This constructor is used by messaging infrastructure to attach a Converter when reconstructing details from raw data received over an infrastructure boundary (for example, a command dispatched through Axon Server). It is not meant to be used directly by application code, which typically already has the details object in its final form and can use CommandExecutionException(String, Throwable, Object) instead.

      Parameters:
      message - the message describing the exception
      cause - the cause of the exception
      details - an object providing more error details, potentially raw data awaiting conversion (maybe null)
      converter - the Converter to lazily apply when HandlerExecutionException.getDetails(Class) is called with a type details does not already match, or null if no such conversion is available
      writableStackTrace - whether the stack trace should be generated (true) or not (false)