vendor/sentry/sentry-symfony/src/EventListener/ErrorListener.php line 24

Open in your IDE?
  1. <?php
  2. namespace Sentry\SentryBundle\EventListener;
  3. use Sentry\State\HubInterface;
  4. use Symfony\Component\Console\Event\ConsoleErrorEvent;
  5. use Symfony\Component\HttpKernel\Event\ExceptionEvent;
  6. use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
  7. final class ErrorListener
  8. {
  9.     /** @var HubInterface */
  10.     private $hub;
  11.     /**
  12.      * ErrorListener constructor.
  13.      * @param HubInterface $hub
  14.      */
  15.     public function __construct(HubInterface $hub)
  16.     {
  17.         $this->hub $hub// not used, needed to trigger instantiation
  18.     }
  19.     public function onException(ExceptionEvent $event): void
  20.     {
  21.         \Sentry\captureException($event->getThrowable());
  22.     }
  23.     /**
  24.      * BC layer for Symfony < 4.3
  25.      */
  26.     public function onKernelException(GetResponseForExceptionEvent $event): void
  27.     {
  28.         \Sentry\captureException($event->getException());
  29.     }
  30.     public function onConsoleError(ConsoleErrorEvent $event): void
  31.     {
  32.         \Sentry\captureException($event->getError());
  33.     }
  34. }