Skip to content

Commit

Permalink
Merge pull request #54 from maximecolin/patch-1
Browse files Browse the repository at this point in the history
Fix deprecated getException on Event
  • Loading branch information
b-viguier authored Mar 10, 2020
2 parents 98c2839 + bd76e2c commit 3fc4f95
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ public function __construct($requestExceptionAttribute)
*/
public function onKernelException(GetResponseForExceptionEvent $event)
{
if (method_exists($event, 'getThrowable')) {
$exception = $event->getThrowable();
} else {
$exception = $event->getException();
}

$request = $event->getRequest();
$request->setRequestFormat('json');
$request->attributes->add([$this->requestExceptionAttribute => $event->getException()]);
$request->attributes->add([$this->requestExceptionAttribute => $exception]);
}
}

0 comments on commit 3fc4f95

Please sign in to comment.