title: Symfony2 throwing 404 inside kernel request event
body: <p>I may be going about this completely the wrong way, but I have a onKernelRequest event setup which picks up the current domain (multi site on a single application), queries cache/db and stores this in the service for use by other controllers/services. This works perfectly.</p>
  
  <p>Now if the domain isn't found, I'd like to throw a 404 error. Usually I'd just do the following in a controller:</p>
  
  <pre><code>throw new NotFoundHttpException('Not found!');
  </code></pre>
  
  <p>But this results in an uncaught exception in production, so I'm assuming due to the priority of the event (31). </p>
  
  <pre><code>PHP Fatal error:  Uncaught exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' with message 'Not found!'
  </code></pre>
  
  <p>My current code (with logic removed for clarity), note I use JMSDiExtraBundle to configure services.</p>
  
  <pre><code>/**
   * @Service
   */
  class CurrentDomainListener
  {
      /**
       * @Observe("kernel.request", priority=31)
       */
      public function onKernelRequest(GetResponseEvent $event)
      {
          // find domain in cache/database...
  
          if (!$domain) {
              throw new NotFoundHttpException('Not found!');
          }
  
          // store domain in service...
      }
  }
  </code></pre>
  
  <p>My question is what would be the best way to display a 404 error when the domain doesn't exist?</p>