Skip to content

Fix 5.0 event get/setThrowable #12716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/http_kernel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``.

Expand Down
2 changes: 1 addition & 1 deletion event_dispatcher.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions reference/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down