Skip to content

Commit 2be0de9

Browse files
mpdudeweaverryan
authored andcommitted
Point out the difference between error and exception pages.
Move section on testing error pages during development into a sidebar and make it shorter.
1 parent e740b3d commit 2be0de9

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

cookbook/controller/error_pages.rst

+19-21
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,30 @@ control you need:
2929
which allows complete control over exception handling. For more
3030
information, see :ref:`kernel-kernel.exception`.
3131

32+
The default ``ExceptionController`` will either display an
33+
*exception* or *error* page, depending on the setting of the ``kernel
34+
.debug`` flag. While *exception* pages give you a lot of helpful
35+
information during development, *error* pages are meant to be
36+
shown to the end-user.
37+
38+
.. sidebar:: Testing error pages during development
39+
40+
Setting ``kernel.debug`` to ``false`` in order to see your
41+
error pages during development is impractical as it also stops
42+
Symfony2 from recompiling your twig templates, among other things.
43+
44+
The third-party `webfactory/exceptions-bundle`_ provides a special
45+
test controller that allows you to display your custom error
46+
pages for arbitrary HTTP status codes even with ``kernel
47+
.debug`` set to ``true``.
48+
3249
All of the error templates live inside the TwigBundle. To override the
3350
templates, simply rely on the standard method for overriding templates that
3451
live inside a bundle. For more information, see
3552
:ref:`overriding-bundle-templates`.
3653

37-
For example, to override the default error template that's shown to the
38-
end-user, create a new template located at
54+
For example, to override the default error template, create a new
55+
template located at
3956
``app/Resources/TwigBundle/views/Exception/error.html.twig``:
4057

4158
.. code-block:: html+jinja
@@ -111,23 +128,4 @@ Symfony uses the following algorithm to determine which template to use:
111128
``exception.html.twig`` for the standard HTML exception page or
112129
``exception.json.twig`` for the JSON exception page.
113130

114-
Testing Error Pages during development
115-
--------------------------------------
116-
117-
The default exception controller,
118-
``Symfony\Bundle\TwigBundle\Controller\ExceptionController``, which is
119-
part of the TwigBundle will show
120-
*exception* pages when you're in ``kernel.debug`` mode and *error*
121-
pages otherwise. Thus, your end users will typically see the *error*
122-
pages.
123-
124-
But setting ``kernel.debug`` to ``false`` during development to write
125-
or test your custom error pages is impractical as it stops Symfony2 from
126-
recompiling the Twig templates, among other things.
127-
128-
To help you with that, `webfactory/exceptions-bundle`_ contains a
129-
simple test controller that you can use to trigger custom exceptions. At
130-
the same time, it will make the `ExceptionController` display the
131-
corresponding *error* pages also in ``kernel.debug`` mode.
132-
133131
.. _`webfactory/exceptions-bundle`: https://github.com/webfactory/exceptions-bundle

0 commit comments

Comments
 (0)