From d76e811aa0e4eed1c957e7406b08c0c8d8e6aa7d Mon Sep 17 00:00:00 2001 From: Bartosz Date: Fri, 10 Feb 2017 10:50:59 +0100 Subject: [PATCH] SkipCapture add to onConsoleException Event --- .../EventListener/ExceptionListener.php | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Sentry/SentryBundle/EventListener/ExceptionListener.php b/src/Sentry/SentryBundle/EventListener/ExceptionListener.php index f875c205..03a9bde1 100644 --- a/src/Sentry/SentryBundle/EventListener/ExceptionListener.php +++ b/src/Sentry/SentryBundle/EventListener/ExceptionListener.php @@ -90,10 +90,9 @@ public function onKernelRequest(GetResponseEvent $event) public function onKernelException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); - foreach ($this->skipCapture as $className) { - if ($exception instanceof $className) { - return; - } + + if ($this->shouldExceptionCaptureBeSkipped($exception)) { + return; } $this->client->captureException($exception); @@ -106,6 +105,10 @@ public function onConsoleException(ConsoleExceptionEvent $event) { $command = $event->getCommand(); $exception = $event->getException(); + + if ($this->shouldExceptionCaptureBeSkipped($exception)) { + return; + } $data = array( 'tags' => array( @@ -116,6 +119,18 @@ public function onConsoleException(ConsoleExceptionEvent $event) $this->client->captureException($exception, $data); } + + private function shouldExceptionCaptureBeSkipped(\Exception $exception) + { + foreach ($this->skipCapture as $className) { + if ($exception instanceof $className) { + return true; + } + } + + return false; + } + /** * @param UserInterface | object | string $user