title: Symfony2 - use a route as an exception page
body: <p>I have looked at so many ways to do this but can't find a solution.</p>
  
  <p>I want my site to show a specific route/page when an exception occurs.</p>
  
  <p>So, if I set it to show the route 'contact' and I go to domain.com/dfergerxyttt (no route found) then it will be the same as if I had gone to domain.com/route (except for a 404 status code).</p>
  
  <p>I need these key things though:
  (1) I need it to run the controller code as it normally would
  (2) I need it to also run my Request event listener code</p>
  
  <p>I can't just set it to show one specific template, it must be the whole request-event-listener and controller etc. process.</p>
  
  <p>I tried an exception listener but it wouldn't run the request listener as well. All that code was ignored.</p>
  
  <p>I can't see a way to just set a catch-all route or anything either. To set a default or a catch-all route would be a good idea.</p>
  
  <p>--</p>
  
  <p>I've tried this, but I can't get access to the controller. Not sure if I need to inject it in or something:</p>
  
  <pre><code>namespace etc...
  
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Symfony\Bundle\TwigBundle\Controller\ExceptionController;
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Component\HttpKernel\HttpKernel;
  use Symfony\Component\HttpKernel\Exception\FlattenException;
  use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
  use Symfony\Component\HttpFoundation\Response;
  
  class MyExceptionController extends ExceptionController
  {
      public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
      {
  
         $httpKernel = $this-&gt;container-&gt;get('kernel');
         $response = $httpKernel-&gt;forward('AcmeMyBundle:Default:pageAction');
         $this-&gt;setResponse(new Response($response));
  
      }
  }
  </code></pre>
  
  <p>I've also done this in services.yml which does seem to be correct:</p>
  
  <pre><code>parameters:
      twig.controller.exception
        class: Acme\MyBundle\MyExceptionController
  </code></pre>