title: Symfony 2 - Get error instead of debug page on test environment / How to set debug to false on test environment (Twig ExceptionController)?
body: <p>I want to get error page (after an exception of the app is trhown) and not the debug page on testing environment.</p>
  
  <p>I have tracked Twig Bundle code and the answer is in the <strong>Symfony\Bundle\TwigBundle\Controller\ExceptionController</strong> class in the findTemplate() method.
  Here I copy the responsible fragment of code that choose the template. </p>
  
  <pre><code>    $name = $debug ? 'exception' : 'error';
      if ($debug &amp;&amp; 'html' == $format) {
          $name = 'exception_full';
      }
  </code></pre>
  
  <p>There is no problem with this code. The point is that I can't set the ExceptionController <strong>$debug</strong> variable to false for my test environment.</p>
  
  <p>Based on <a href="http://symfony.com/doc/2.2/reference/configuration/twig.html" rel="nofollow noreferrer">TwigBundle Configuration Reference</a>, it should be enough to set the debug parametar to false in <strong>config_test.yml</strong>.</p>
  
  <pre><code>twig:
    debug:       false
  </code></pre>
  
  <p>This is notworking.</p>
  
  <p>I have browsed Symfony code and found this fragment configuration on <strong>vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml</strong>.</p>
  
  <pre><code>    &lt;service id="twig.controller.exception" class="%twig.controller.exception.class%"&gt;
          &lt;argument type="service" id="twig" /&gt;
          &lt;argument&gt;%kernel.debug%&lt;/argument&gt;
      &lt;/service&gt;
  </code></pre>
  
  <p>So, no matter what do I set on my configuration files, debug variable value is not modified.</p>
  
  <p>What do you think about it?</p>
  
  <p>I am working with Symfony 2.2.1 and this question is kind of related with <a href="https://stackoverflow.com/questions/10651403/symfony2-display-404-error-page-in-dev">this other question</a>.</p>