Skip to content

Commit ced72a0

Browse files
rdohmsJean85
authored andcommitted
Cherry picked from commit cc98155 to merge #67
1 parent 5454110 commit ced72a0

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/Sentry/SentryBundle/EventListener/ExceptionListener.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Sentry\SentryBundle\Event\SentryUserContextEvent;
66
use Sentry\SentryBundle\SentrySymfonyClient;
77
use Sentry\SentryBundle\SentrySymfonyEvents;
8+
use Symfony\Component\Console\Event\ConsoleCommandEvent;
89
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
910
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1011
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
@@ -110,6 +111,19 @@ public function onKernelException(GetResponseForExceptionEvent $event)
110111
$this->client->captureException($exception);
111112
}
112113

114+
/**
115+
* This method only ensures that the client and error handlers are registered at the start of the command
116+
* execution cycle, and not only on exceptions
117+
*
118+
* @param ConsoleCommandEvent $event
119+
*
120+
* @return void
121+
*/
122+
public function onConsoleCommand(ConsoleCommandEvent $event)
123+
{
124+
// only triggers loading of client, does not need to do anything.
125+
}
126+
113127
/**
114128
* @param ConsoleExceptionEvent $event
115129
*/

src/Sentry/SentryBundle/Resources/config/services.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ services:
2121
tags:
2222
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: '%sentry.listener_priorities.request%'}
2323
- { name: kernel.event_listener, event: kernel.exception, method: onKernelException, priority: '%sentry.listener_priorities.kernel_exception%' }
24+
- { name: kernel.event_listener, event: console.command, method: onConsoleCommand }
2425
- { name: kernel.event_listener, event: console.exception, method: onConsoleException, priority: '%sentry.listener_priorities.console_exception%' }

test/Sentry/SentryBundle/Test/DependencyInjection/ExtensionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ public function test_that_it_has_proper_event_listener_tags_for_exception_listen
290290
array(
291291
array('event' => 'kernel.request', 'method' => 'onKernelRequest', 'priority' => '%sentry.listener_priorities.request%' ),
292292
array('event' => 'kernel.exception', 'method' => 'onKernelException', 'priority' => '%sentry.listener_priorities.kernel_exception%'),
293+
array('event' => 'console.command', 'method' => 'onConsoleCommand'),
293294
array('event' => 'console.exception', 'method' => 'onConsoleException', 'priority' => '%sentry.listener_priorities.console_exception%'),
294295
),
295296
$tags

0 commit comments

Comments
 (0)