Skip to content

Commit d76e811

Browse files
authored
SkipCapture add to onConsoleException Event
1 parent 5c50287 commit d76e811

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/Sentry/SentryBundle/EventListener/ExceptionListener.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,9 @@ public function onKernelRequest(GetResponseEvent $event)
9090
public function onKernelException(GetResponseForExceptionEvent $event)
9191
{
9292
$exception = $event->getException();
93-
foreach ($this->skipCapture as $className) {
94-
if ($exception instanceof $className) {
95-
return;
96-
}
93+
94+
if ($this->shouldExceptionCaptureBeSkipped($exception)) {
95+
return;
9796
}
9897

9998
$this->client->captureException($exception);
@@ -106,6 +105,10 @@ public function onConsoleException(ConsoleExceptionEvent $event)
106105
{
107106
$command = $event->getCommand();
108107
$exception = $event->getException();
108+
109+
if ($this->shouldExceptionCaptureBeSkipped($exception)) {
110+
return;
111+
}
109112

110113
$data = array(
111114
'tags' => array(
@@ -116,6 +119,18 @@ public function onConsoleException(ConsoleExceptionEvent $event)
116119

117120
$this->client->captureException($exception, $data);
118121
}
122+
123+
private function shouldExceptionCaptureBeSkipped(\Exception $exception)
124+
{
125+
foreach ($this->skipCapture as $className) {
126+
if ($exception instanceof $className) {
127+
return true;
128+
}
129+
}
130+
131+
return false;
132+
}
133+
119134

120135
/**
121136
* @param UserInterface | object | string $user

0 commit comments

Comments
 (0)