Skip to content

Commit 5810098

Browse files
committed
Implement fix into the ErrorListener
1 parent 8921f17 commit 5810098

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/EventListener/ErrorListener.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Sentry\State\HubInterface;
88
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
9+
use Symfony\Component\Messenger\Exception\HandlerFailedException;
910

1011
/**
1112
* This listener listens for error events and logs them to Sentry.
@@ -36,9 +37,17 @@ public function handleExceptionEvent(ErrorListenerExceptionEvent $event): void
3637
{
3738
/** @psalm-suppress RedundantCondition */
3839
if ($event instanceof ExceptionEvent) {
39-
$this->hub->captureException($event->getThrowable());
40+
$error = $event->getThrowable();
4041
} else {
41-
$this->hub->captureException($event->getException());
42+
$error = $event->getException();
43+
}
44+
45+
if ($error instanceof HandlerFailedException) {
46+
foreach ($error->getNestedExceptions() as $nestedException) {
47+
$this->hub->captureException($nestedException);
48+
}
49+
} else {
50+
$this->hub->captureException($error);
4251
}
4352
}
4453
}

0 commit comments

Comments
 (0)