Skip to content

Commit 55d6a36

Browse files
Fix deprecated getException on Event (#69)
* Fix deprecated getException on Event * fix: trim whitespaces Co-authored-by: Oliver THEBAULT <Oliboy50@users.noreply.github.com>
1 parent e125929 commit 55d6a36

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/Statsd/Listener.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@ public function __construct(Client $statsdClient, EventDispatcherInterface $even
3636
*/
3737
public function onKernelException(ExceptionEvent $event)
3838
{
39-
$exception = $event->getThrowable();
39+
// @TODO: remove this backward compatibility layer after symfony 4.4 has been dropped
40+
if (method_exists($event, 'getThrowable')) {
41+
$exception = $event->getThrowable();
42+
} else {
43+
$exception = $event->getException();
44+
}
45+
4046
if ($exception instanceof HttpExceptionInterface) {
41-
$code = $event->getThrowable()->getStatusCode();
47+
$code = $exception->getStatusCode();
4248
} else {
4349
$code = 'unknown';
4450
}
51+
4552
$this->eventDispatcher->dispatch(
4653
new StatsdEvent($code),
4754
'statsd.exception'

0 commit comments

Comments
 (0)