Skip to content

[2.2] custom error pages seem to be broken #7366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
craue opened this issue Mar 13, 2013 · 7 comments
Closed

[2.2] custom error pages seem to be broken #7366

craue opened this issue Mar 13, 2013 · 7 comments

Comments

@craue
Copy link
Contributor

craue commented Mar 13, 2013

With 2.1.8, I'm using the twig.exception_controller config option to specify a custom exception controller (using the bundle notation) to be able to check in the dev env how my custom error pages (like app/Resources/TwigBundle/views/Exception/error404.html.twig) would look like. After upgrading to 2.2.0 and some code changes to my exception controller (changed method signature of showAction), I'm unable to let my custom error pages being rendered, neither using that exception controller in dev env (showAction is not called at all) nor in the prod env (just a blank page, not even a default error page).

Did something change in handling custom error pages or using a custom exception controller? The UPGRADE file doesn't mention anything and I can't spot any difference between http://symfony.com/doc/2.1/cookbook/controller/error_pages.html and http://symfony.com/doc/2.2/cookbook/controller/error_pages.html.

@zd-dalibor
Copy link

I have exactly the same problem. My error pages don't render "Symfony\Bundle\TwigBundle\Controller\ExceptionController" anymore instead It likes in symfony 2.2.0 error pages are rendered with "Symfony\Component\HttpKernel\Debug\ExceptionHandler" in dev environment. In prod error pages are not rendered at all. I can't get symfony 2.2.0 to render my custom error pages in prod environment.

@zd-dalibor
Copy link

I found solution.
If you want to replace default twig error controller with your own first you must create your own controller that extend "Symfony\Bundle\TwigBundle\Controller\ExceptionController" and override "showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')" method or create controller like "Symfony\Bundle\TwigBundle\Controller\ExceptionController".
Second you must register this controller as service like this for example

<parameters>
    <parameter key="my_twig.controller.exception.class">Bundle\MyTwigBundle\Controller\ExceptionController</parameter>
</parameters>

<services>
    <service id="my_twig.controller.exception" class="%my_twig.controller.exception.class%">
        <argument type="service" id="twig" />
        <argument>%kernel.debug%</argument>
    </service>
</services>

Third in your configuration file (config.yml) add this

twig:
    exception_controller: my_twig.controller.exception:showAction

not like documentation says

twig:
    exception_controller: <full_namespace\controller_name>::showAction

This should be added in documentation for symfony 2.2.0

@craue
Copy link
Contributor Author

craue commented Mar 20, 2013

So this can be considered as a not yet documented BC break? The change is only mentioned in TwigBundle's CHANGELOG file in 35d63df.

The service definition can be stripped down a bit to something like

<service id="my_twig.controller.exception"
        class="%my_twig.controller.exception.class%"
        parent="twig.controller.exception">
</service>

@zd-dalibor
Copy link

@craue I agree with your service definition.

@mpdude
Copy link
Contributor

mpdude commented Mar 21, 2013

That bug aside, would #7446 also meet your needs?

@davidmles
Copy link

The reference needs to be updated: http://symfony.com/doc/2.2/reference/configuration/twig.html#config-twig-exception-controller

In SO there is an answer to this problem as well: http://stackoverflow.com/a/15773923/267705

@fabpot
Copy link
Member

fabpot commented Apr 28, 2014

Closing this old ticket.

@fabpot fabpot closed this as completed Apr 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants