Skip to content

Commit 334492a

Browse files
Reorder page from simple to advanced
As a followup on symfony/symfony#10980 I want to propose to reorder the page as the obvious way should come first. I took me way to long to find the correct way :p I added two headers - The default ExceptionController - Override error templates in order to introduce how override works and moved the controller override to the bottom as that is more advanced.
1 parent 5a4eb57 commit 334492a

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

cookbook/controller/error_pages.rst

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,12 @@ the status code that should be set for the given exception.
1414
Error pages can be customized in two different ways, depending on how much
1515
control you need:
1616

17-
1. Customize the error templates of the different error pages (explained below);
17+
1. Customize the error templates of the different error pages;
1818

1919
2. Replace the default exception controller ``twig.controller.exception:showAction``
20-
with your own controller and handle it however you want (see
21-
:ref:`exception_controller in the Twig reference <config-twig-exception-controller>`).
22-
The default exception controller is registered as a service - the actual
23-
class is ``Symfony\Bundle\TwigBundle\Controller\ExceptionController``.
24-
25-
.. tip::
26-
27-
The customization of exception handling is actually much more powerful
28-
than what's written here. An internal event, ``kernel.exception``, is thrown
29-
which allows complete control over exception handling. For more
30-
information, see :ref:`kernel-kernel.exception`.
3120

21+
The default ExceptionController
22+
-------------------------------
3223
The default ``ExceptionController`` will either display an
3324
*exception* or *error* page, depending on the setting of the ``kernel.debug``
3425
flag. While *exception* pages give you a lot of helpful
@@ -46,6 +37,9 @@ shown to the end-user.
4637
pages for arbitrary HTTP status codes even with
4738
``kernel.debug`` set to ``true``.
4839

40+
Override error templates
41+
------------------------
42+
4943
All of the error templates live inside the TwigBundle. To override the
5044
templates, simply rely on the standard method for overriding templates that
5145
live inside a bundle. For more information, see
@@ -129,3 +123,19 @@ Symfony uses the following algorithm to determine which template to use:
129123
``exception.json.twig`` for the JSON exception page.
130124

131125
.. _`WebfactoryExceptionsBundle`: https://github.com/webfactory/exceptions-bundle
126+
127+
Replace the default exception controller
128+
----------------------------------------
129+
130+
Replace the default exception controller ``twig.controller.exception:showAction``
131+
with your own controller and handle it however you want (see
132+
:ref:`exception_controller in the Twig reference <config-twig-exception-controller>`).
133+
The default exception controller is registered as a service - the actual
134+
class is ``Symfony\Bundle\TwigBundle\Controller\ExceptionController``.
135+
136+
.. tip::
137+
138+
The customization of exception handling is actually much more powerful
139+
than what's written here. An internal event, ``kernel.exception``, is thrown
140+
which allows complete control over exception handling. For more
141+
information, see :ref:`kernel-kernel.exception`.

0 commit comments

Comments
 (0)