Skip to content

Commit 7ea412c

Browse files
committed
minor #13214 Adds exception template variable available in custom error pages (dbrumann)
This PR was squashed before being merged into the 4.4 branch (closes #13214). Discussion ---------- Adds exception template variable available in custom error pages Alongside `status_code` and `status_text` you also have access to `exception` template variable in custom error pages. Commits ------- 60f3c8a Adds exception template variable available in custom error pages
2 parents 810d099 + 60f3c8a commit 7ea412c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

components/error_handler.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ enable each of them separately.
4343
You should never enable the debug tools, except for the error handler, in a
4444
production environment as they might disclose sensitive information to the user.
4545

46+
.. _turning-php-errors-into-exceptions:
47+
4648
Turning PHP Errors into Exceptions
4749
----------------------------------
4850

controller/error_pages.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ store the HTTP status code and message respectively.
118118
and its required ``getStatusCode()`` method. Otherwise, the ``status_code``
119119
will default to ``500``.
120120

121+
Additionally you have access to the Exception with ``exception``, which for example
122+
allows you to output the stack trace using ``{{ exception.traceAsString }}`` or
123+
access any other method on the object. You should be careful with this though,
124+
as this is very likely to expose sensitive data.
125+
126+
.. tip::
127+
128+
PHP errors are turned into exceptions as well by default, so you can also access these
129+
error details using ``exception``. For more on this see
130+
:ref:`Turning PHP Errors into Exceptions <turning-php-errors-into-exceptions>`
131+
121132
Security & 404 Pages
122133
--------------------
123134

0 commit comments

Comments
 (0)