From 12ff6ad8a71f7c5a10106eeb41c91e353636e9ce Mon Sep 17 00:00:00 2001 From: Teoh Han Hui Date: Wed, 18 Sep 2019 16:41:18 +0200 Subject: [PATCH] Fix ErrorListener not capturing events when Hub is not instantiated yet --- src/EventListener/ErrorListener.php | 13 +++++++++++++ src/Resources/config/services.xml | 1 + 2 files changed, 14 insertions(+) diff --git a/src/EventListener/ErrorListener.php b/src/EventListener/ErrorListener.php index 862cfe7a..14f1eb91 100644 --- a/src/EventListener/ErrorListener.php +++ b/src/EventListener/ErrorListener.php @@ -2,12 +2,25 @@ namespace Sentry\SentryBundle\EventListener; +use Sentry\State\HubInterface; use Symfony\Component\Console\Event\ConsoleErrorEvent; use Symfony\Component\Console\Event\ConsoleExceptionEvent; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; final class ErrorListener { + /** @var HubInterface */ + private $hub; + + /** + * ErrorListener constructor. + * @param HubInterface $hub + */ + public function __construct(HubInterface $hub) + { + $this->hub = $hub; // not used, needed to trigger instantiation + } + public function onKernelException(GetResponseForExceptionEvent $event): void { \Sentry\captureException($event->getException()); diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index e45c32ed..df467a04 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -31,6 +31,7 @@ +