Package org.axonframework.messaging.core
Class HandlerExecutionException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.axonframework.common.AxonException
org.axonframework.messaging.core.HandlerExecutionException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CommandExecutionException,QueryExecutionException
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 Summary
ConstructorsConstructorDescriptionHandlerExecutionException(String message) Initializes an execution exception with givenmessage.HandlerExecutionException(String message, Throwable cause) Initializes an execution exception with givenmessageandcause.HandlerExecutionException(String message, Throwable cause, Object details) Initializes an execution exception with givenmessage,causeand application-specificdetails.HandlerExecutionException(String message, Throwable cause, Object details, boolean writableStackTrace) Initializes an execution exception with givenmessage,cause, application-specificdetails, andwritableStackTrace -
Method Summary
Modifier and TypeMethodDescription<R> Optional<R> Returns an Optional containing application-specific details of the exception, if any were provided.static <R> Optional<R> resolveDetails(Throwable throwable) Resolve details from the giventhrowable, taking into account that the details may be available in any of theHandlerExecutionExceptions is the "cause" chain.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
HandlerExecutionException
Initializes an execution exception with givenmessage. The cause and application-specific details are set tonull.- Parameters:
message- A message describing the exception
-
HandlerExecutionException
Initializes an execution exception with givenmessageandcause. The application-specific details are set tonull.- Parameters:
message- A message describing the exceptioncause- the cause of the execution exception
-
HandlerExecutionException
Initializes an execution exception with givenmessage,causeand application-specificdetails.- Parameters:
message- A message describing the exceptioncause- The cause of the execution exceptiondetails- 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 givenmessage,cause, application-specificdetails, andwritableStackTrace- Parameters:
message- A message describing the exceptioncause- The cause of the execution exceptiondetails- An object providing application-specific details of the exceptionwritableStackTrace- Whether the stack trace should be generated (true) or not (false)
-
-
Method Details
-
resolveDetails
Resolve details from the giventhrowable, taking into account that the details may be available in any of theHandlerExecutionExceptions 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
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 aClassCastExceptionfurther downstream, when accessing the Optional's enclosed value.- Type Parameters:
R- The type of details expected- Returns:
- an Optional containing the details, if provided
-