Closed
Description
Description
I'm using the messenger component as a sync bus. Its similiar to the HandleTrait.
Since Messenger 4.3 the messenger bus wraps all exception in a HandleFailedException. So if my handler for example throws a EntityNotFoundException
that EntityNotFoundException
will get wrapped by the HandleFailedException
and so I'm not able to catch directly the EntityNotFoundException
in the service which did call dispatch.
Example
try {
$this->messageBus->dispatch(new ModifyEventMessage($id)); // Handler can throws a EntityNotFoundException
} catch (EntityNotFoundException $e) {
// never called
}
instead I would need currently do something like:
try {
try {
$this->messageBus->dispatch(new ModifyEventMessage($id)); // Handler can throws a EntityNotFoundException
} catch (HandleFailedException $e) {
/** @var \Throwable $previous */
$previous = $e->getPrevious();
throw $previous;
}
} catch (EntityNotFoundException $e) {
// ...
}
It would be great if there is a configuraiton which make it possible to disable that the real exception is thrown instead of the HandleFailedException. Hints welcome how this could be implemented.