HandlerExecutionExceptionmarks an exception which originates from a message handling member. Since an Event message is unidirectional, handling an event does not include any return values. As such, the
HandlerExecutionExceptionshould only be returned as an exceptional result from handling a command. Axon provides a more concrete implementation of this exception for failed command and query handling, respectively the
HandlerExecutionException. It is thus recommended to throw a
QueryExecutionExceptionwith the required details, when command/query handling fails. This behaviour could be supported generically by implementing interceptors which perform exception wrapping for you.
@ExceptionHandlerto provide more fine-grained control on how to react to exceptions. More specifically, this is a type of message handler interceptor dedicated to reacting to exceptional results. Note that such an
@ExceptionHandlerwill only handle exceptions thrown from message handling functions in the same class. For more specifics on how to use this annotation, check out this section.