Skip to content

Commit 3ad1c6c

Browse files
Added feedback from @weaverryan with a little move around.
1 parent 10ed835 commit 3ad1c6c

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

cookbook/controller/error_pages.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ shown to the end-user.
3535

3636
The third-party `WebfactoryExceptionsBundle`_ provides a special
3737
test controller that allows you to display your custom error
38-
pages for arbitrary HTTP status codes even with
38+
pages for arbitrary HTTP status codes even with
3939
``kernel.debug`` set to ``true``.
4040

4141
Override Error Templates
@@ -128,12 +128,25 @@ Symfony uses the following algorithm to determine which template to use:
128128
Replace the default Exception Controller
129129
----------------------------------------
130130

131-
Replace the default exception controller ``twig.controller.exception:showAction``
132-
with your own controller and handle it however you want (see
133-
:ref:`exception_controller in the Twig reference <config-twig-exception-controller>`).
131+
If you need a little more flexibility beyond just overriding the template
132+
(e.g. you need to pass some additional variables into your template),
133+
then you can override the controller that renders the error page.
134+
134135
The default exception controller is registered as a service - the actual
135136
class is ``Symfony\Bundle\TwigBundle\Controller\ExceptionController``.
136137

138+
To do this, create a new controller class and make it extend Symfony's default
139+
Symfony\Bundle\TwigBundle\Controller\ExceptionController class.
140+
141+
There are several methods you can override to customize different parts of how
142+
the error page is rendered. You could ie replace the default exception
143+
controller ``twig.controller.exception:showAction`` with your own method
144+
and handle it however you want.
145+
146+
To make Symfony use your exception controller instead of the default, set the
147+
:ref:`twig.exception_controller <config-twig-exception-controller> option
148+
in app/config/config.yml.
149+
137150
.. tip::
138151

139152
The customization of exception handling is actually much more powerful

0 commit comments

Comments
 (0)