title: symfony 4 - bugsnag - Ignore specific exception type
body: <p>I use bugsnag to log errors for our app. The app is built over symfony 4 and I have a custom listener that catches exceptions and treats some of them. What I need is to tell bugsnag to ignore the exceptions that I manually handle (there is no need for them to be logged since they are already treated).</p>
  
  <p>My custom listener has higher priority than bugsnag listener (so is ran first). The problem is that stopping event propagation breaks other stuff (for example security listener is not run any more since it has lower priority than bugsnag by default).</p>
  
  <p>Below is my listener code (well... relevant part of it):</p>
  
  <pre><code>class ExceptionListener
  {
  
  protected $router;
  private $mailerService;
  private $tokenStorage;
  private $request;
  private $em;
  /**
   * @var UtilsService
   */
  private $utilsService;
  
  public function __construct(Router $router, MailerService $mailerService, TokenStorageInterface $tokenStorage, RequestStack $request, EntityManagerInterface $em, UtilsService $utilsService)
  {
      $this-&gt;router = $router;
      $this-&gt;mailerService = $mailerService;
      $this-&gt;tokenStorage = $tokenStorage;
      $this-&gt;request = $request;
      $this-&gt;em = $em;
      $this-&gt;utilsService = $utilsService;
  }
  
  public function onKernelException(ExceptionEvent $event)
  {
      $exception = $event-&gt;getException();
      $message = $exception-&gt;getMessage();
  
      switch (true) {
          case $exception instanceof NotFoundHttpException:
               // Redirect somewhere
          break;
          case $exception instanceof CustomException:
               // Do some stuff
               $event-&gt;stopPropagation(); // This does what I need (stops propagation to bugsnag listener) but breaks other things so is not a solution (since it stops propagation to everything).
          break;
      }
  
      return false;
  }
  }
  </code></pre>
  
  <p>What I need is simple... in case the exception thrown is an instance of CustomException I want it NOT to be sent to bugsnag.</p>
  
  <p>The 2 possible solutions that I see are (others are welcomed ofc):</p>
  
  <ul>
  <li><p>tell bugsnag to ignore that exception somehow: In bugsnag documentation I find how to do this for Laravel (<a href="https://docs.bugsnag.com/platforms/php/laravel/configuration-options/" rel="noreferrer">https://docs.bugsnag.com/platforms/php/laravel/configuration-options/</a> - using dontReport) and Ruby (<a href="https://docs.bugsnag.com/platforms/ruby/other/configuration-options/#ignore_classes" rel="noreferrer">https://docs.bugsnag.com/platforms/ruby/other/configuration-options/#ignore_classes</a>), but not for Symfony. Any idea how to do this?</p></li>
  <li><p>stop propagation of the event only for the bugsnag listener: I found no documentation regarding this whatsoever. Any idea how to do this?</p></li>
  </ul>