Skip to content

Commit 3972749

Browse files
committed
Handle capturing of exceptions implementing WrappedExceptionsInterface
1 parent 71fe1eb commit 3972749

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/EventListener/MessengerListener.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Symfony\Component\Messenger\Event\WorkerMessageHandledEvent;
1414
use Symfony\Component\Messenger\Exception\DelayedMessageHandlingException;
1515
use Symfony\Component\Messenger\Exception\HandlerFailedException;
16+
use Symfony\Component\Messenger\Exception\WrappedExceptionsInterface;
1617
use Symfony\Component\Messenger\Stamp\BusNameStamp;
1718

1819
final class MessengerListener
@@ -94,9 +95,11 @@ public function handleWorkerMessageHandledEvent(WorkerMessageHandledEvent $event
9495
*/
9596
private function captureException(\Throwable $exception, bool $willRetry): void
9697
{
97-
if ($exception instanceof HandlerFailedException) {
98+
if ($exception instanceof WrappedExceptionsInterface) {
99+
$exception = $exception->getWrappedExceptions();
100+
} elseif ($exception instanceof HandlerFailedException && method_exists($exception, 'getNestedExceptions')) {
98101
$exception = $exception->getNestedExceptions();
99-
} elseif ($exception instanceof DelayedMessageHandlingException) {
102+
} elseif ($exception instanceof DelayedMessageHandlingException && method_exists($exception, 'getExceptions')) {
100103
$exception = $exception->getExceptions();
101104
}
102105

0 commit comments

Comments
 (0)