Class HandlerExecutionException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CommandExecutionException, QueryExecutionException

public abstract class HandlerExecutionException extends AxonException
Base exception for exceptions raised by Handler methods. Besides standard exception information (such as message and cause), these exception may optionally carry an object with additional application-specific details about the exception.

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:
4.2
Author:
Allard Buize
See Also:
  • Constructor Details

    • HandlerExecutionException

      public HandlerExecutionException(String message)
      Initializes an execution exception with given message. The cause and application-specific details are set to null.
      Parameters:
      message - A message describing the exception
    • HandlerExecutionException

      public HandlerExecutionException(String message, Throwable cause)
      Initializes an execution exception with given message and cause. The application-specific details are set to null.
      Parameters:
      message - A message describing the exception
      cause - the cause of the execution exception
    • HandlerExecutionException

      public HandlerExecutionException(String message, Throwable cause, Object details)
      Initializes an execution exception with given message, cause and application-specific details.
      Parameters:
      message - A message describing the exception
      cause - The cause of the execution exception
      details - An object providing application-specific details of the exception
    • HandlerExecutionException

      public HandlerExecutionException(String message, Throwable cause, Object details, boolean writableStackTrace)
      Initializes an execution exception with given message, cause, application-specific details, and writableStackTrace
      Parameters:
      message - A message describing the exception
      cause - The cause of the execution exception
      details - An object providing application-specific details of the exception
      writableStackTrace - Whether the stack trace should be generated (true) or not (false)
  • Method Details

    • resolveDetails

      public static <R> Optional<R> resolveDetails(Throwable throwable)
      Resolve details from the given throwable, taking into account that the details may be available in any of the HandlerExecutionExceptions is the "cause" chain.
      Type Parameters:
      R - The type of details expected
      Parameters:
      throwable - The exception to resolve the details from
      Returns:
      an Optional containing details, if present in the given throwable
    • getDetails

      public <R> Optional<R> getDetails()
      Returns an Optional containing application-specific details of the exception, if any were provided. These details are implicitly cast to the expected type. A mismatch in type may lead to a ClassCastException further downstream, when accessing the Optional's enclosed value.
      Type Parameters:
      R - The type of details expected
      Returns:
      an Optional containing the details, if provided