diff --git a/src/Symfony/Component/HttpKernel/Event/ExceptionEvent.php b/src/Symfony/Component/HttpKernel/Event/ExceptionEvent.php index a4de24b951..a10741a84d 100644 --- a/src/Symfony/Component/HttpKernel/Event/ExceptionEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/ExceptionEvent.php @@ -29,28 +29,23 @@ use Symfony\Component\HttpKernel\HttpKernelInterface; */ final class ExceptionEvent extends RequestEvent { - /** - * The exception object. - * - * @var \Exception - */ - private $exception; + private $throwable; /** * @var bool */ private $allowCustomResponseCode = false; - public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, \Exception $e) + public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, \Throwable $e) { parent::__construct($kernel, $request, $requestType); - $this->setException($e); + $this->setThrowable($e); } - public function getException(): \Exception + public function getThrowable(): \Throwable { - return $this->exception; + return $this->throwable; } /** @@ -58,9 +53,9 @@ final class ExceptionEvent extends RequestEvent * * This exception will be thrown if no response is set in the event. */ - public function setException(\Exception $exception): void + public function setThrowable(\Throwable $exception): void { - $this->exception = $exception; + $this->throwable = $exception; } /** diff --git a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php index 1e9aadac52..0f14c43426 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php @@ -42,9 +42,9 @@ class ExceptionListener implements EventSubscriberInterface public function logKernelException(ExceptionEvent $event) { - $e = FlattenException::createFromThrowable($event->getException()); + $e = FlattenException::createFromThrowable($event->getThrowable()); - $this->logException($event->getException(), sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), $e->getFile(), $e->getLine())); + $this->logException($event->getThrowable(), sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), $e->getFile(), $e->getLine())); } public function onKernelException(ExceptionEvent $event, string $eventName = null, EventDispatcherInterface $eventDispatcher = null) @@ -53,7 +53,7 @@ class ExceptionListener implements EventSubscriberInterface return; } - $exception = $event->getException(); + $exception = $event->getThrowable(); $request = $this->duplicateRequest($exception, $event->getRequest()); try { @@ -98,7 +98,7 @@ class ExceptionListener implements EventSubscriberInterface ]; } - protected function logException(\Exception $exception, string $message) + protected function logException(\Throwable $exception, string $message) { if (null !== $this->logger) { if (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) { @@ -112,7 +112,7 @@ class ExceptionListener implements EventSubscriberInterface /** * Clones the request for the exception. */ - protected function duplicateRequest(\Exception $exception, Request $request): Request + protected function duplicateRequest(\Throwable $exception, Request $request): Request { $attributes = [ '_controller' => $this->controller,