@@ -27,28 +27,31 @@ Error pages for the production environment can be customized in different ways
27
27
depending on your needs:
28
28
29
29
#. If you just want to change the contents and styles of the error pages to match
30
- the rest of your application, :ref: `override default error templates <use-default-exception-controller >`.
30
+ the rest of your application, :ref: `override default error templates <use-default-exception-controller >`;
31
31
32
32
#. If you also want to tweak the logic used by Symfony to generate error pages,
33
- :ref: `override the default exception controller <custom-exception-controller >`.
33
+ :ref: `override the default exception controller <custom-exception-controller >`;
34
34
35
35
#. If you need total control of exception handling to execute your own logic
36
36
:ref: `use the kernel.exception event <use-kernel-exception-event >`.
37
37
38
38
.. _use-default-exception-controller :
39
+ .. _using-the-default-exceptioncontroller :
39
40
40
41
Overriding the Default Error Templates
41
42
--------------------------------------
42
43
43
- By default, when an exception occurs, the ``showAction() `` method of the
44
+ By default, the ``showAction() `` method of the
44
45
:class: `Symfony\\ Bundle\\ TwigBundle\\ Controller\\ ExceptionController ` is called
45
- thanks to an event listener configured by the TwigBundle.
46
+ whenever an exception occurs, thanks to an event listener configured by the TwigBundle.
46
47
47
48
Then, the controller selects one of the templates defined in the
48
49
``Resources/views/Exception `` directory of the TwigBundle to render the error
49
50
page. If you browse that directory (usually located in
50
51
``vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle ``) you'll find a lot of
51
- templates defined for different types of errors and content formats.
52
+ templates defined for different types of errors and content formats
53
+ (``error.*.twig `` templates are used in the production environment whereas
54
+ ``exception.*.twig `` templates are used in the development environment).
52
55
53
56
.. _cookbook-error-pages-by-status-code :
54
57
@@ -96,10 +99,10 @@ store the HTTP status code and message respectively.
96
99
97
100
.. tip ::
98
101
99
- If your application defines custom exceptions and they implement the
100
- :class: `Symfony\\ Component\\ HttpKernel\\ Exception\\ HttpExceptionInterface `,
101
- the `` status_code `` variable will contain the value returned by the
102
- `` getStatusCode() `` method. Otherwise, the `` status_code `` variable will be ``500 ``.
102
+ You can customize the status code by implementing
103
+ :class: `Symfony\\ Component\\ HttpKernel\\ Exception\\ HttpExceptionInterface `
104
+ and its required `` getStatusCode() `` method. Otherwise, the `` status_code ``
105
+ will default to ``500 ``.
103
106
104
107
.. note ::
105
108
0 commit comments