From f9c8a036063a86e28af42d24d351706acd3cc12f Mon Sep 17 00:00:00 2001 From: Jerzy Zawadzki Date: Wed, 27 Nov 2019 22:10:31 +0100 Subject: [PATCH] Fix 5.0 event get/setThrowable --- components/http_kernel.rst | 2 +- event_dispatcher.rst | 2 +- reference/events.rst | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/http_kernel.rst b/components/http_kernel.rst index a82bf961965..19f52b757ce 100644 --- a/components/http_kernel.rst +++ b/components/http_kernel.rst @@ -526,7 +526,7 @@ to the exception. Each listener to this event is passed a :class:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent` object, which you can use to access the original exception via the -:method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getException` +:method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getThrowable` method. A typical listener on this event will check for a certain type of exception and create an appropriate error ``Response``. diff --git a/event_dispatcher.rst b/event_dispatcher.rst index 299aa4d0624..d26b990a7b8 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -35,7 +35,7 @@ The most common way to listen to an event is to register an **event listener**:: public function onKernelException(ExceptionEvent $event) { // You get the exception object from the received event - $exception = $event->getException(); + $exception = $event->getThrowable(); $message = sprintf( 'My Error says: %s with code: %s', $exception->getMessage(), diff --git a/reference/events.rst b/reference/events.rst index d6d7b669573..b7eec4d8dbd 100644 --- a/reference/events.rst +++ b/reference/events.rst @@ -239,14 +239,14 @@ sent as response:: public function onKernelException(ExceptionEvent $event) { - $exception = $event->getException(); + $exception = $event->getThrowable(); $response = new Response(); // setup the Response object based on the caught exception $event->setResponse($response); // you can alternatively set a new Exception // $exception = new \Exception('Some special exception'); - // $event->setException($exception); + // $event->setThrowable($exception); } .. note::