Hi folks!
Before symfony/messenger v4.3, the exceptions were transparent - you got what you threw. So that you could specify them in the exception_to_status map and receive meaningful statuses.
As of v4.3, symfony/messenger started wrapping any exception into HandlerFailedException, so api-platform always returns 500.
Here is a similar issue described in SO https://stackoverflow.com/questions/55558350/custom-exception-from-messenger-handler
So the idea is to recover previous exception and match to exception_to_status map.
if ($exception instanceof HandlerFailedException) {
$exception = $exception->getPrevious();
}
What do you think of this approach? Does it make sense or I'm missing something?
Hi folks!
Before symfony/messenger v4.3, the exceptions were transparent - you got what you threw. So that you could specify them in the exception_to_status map and receive meaningful statuses.
As of v4.3, symfony/messenger started wrapping any exception into HandlerFailedException, so api-platform always returns 500.
Here is a similar issue described in SO https://stackoverflow.com/questions/55558350/custom-exception-from-messenger-handler
So the idea is to recover previous exception and match to exception_to_status map.
What do you think of this approach? Does it make sense or I'm missing something?