Skip to content

Commit 17d83d8

Browse files
committedMay 24, 2023
minor #18331 Improve error_pages.rst (edent)
This PR was submitted for the 6.2 branch but it was merged into the 5.4 branch instead. Discussion ---------- Improve error_pages.rst I couldn't find any explicit documentation about `{{ exception.message }}` This adds it in and provides a link to to class so that readers can find the other methods available. <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `6.x` for features of unreleased versions). --> Commits ------- 0cc61f7 Update error_pages.rst
2 parents 4d3feea + 0cc61f7 commit 17d83d8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

‎controller/error_pages.rst

+8-4
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,14 @@ store the HTTP status code and message respectively.
114114
and its required ``getStatusCode()`` method. Otherwise, the ``status_code``
115115
will default to ``500``.
116116

117-
Additionally you have access to the Exception with ``exception``, which for example
118-
allows you to output the stack trace using ``{{ exception.traceAsString }}`` or
119-
access any other method on the object. You should be careful with this though,
120-
as this is very likely to expose sensitive data.
117+
Additionally you have access to the Exception with ``exception``.
118+
This allows you to access any method of :class:`Symfony\\Component\\HttpKernel\\Exception\\HttpException`.
119+
For example, if an exception message has been set, using
120+
``throw $this->createNotFoundException('The product does not exist');``,
121+
this can be accessed with ``{{ exception.message }}``.
122+
You can output the stack trace using ``{{ exception.traceAsString }}``
123+
You should be careful with this though, as it is very likely to expose
124+
sensitive data.
121125

122126
.. tip::
123127

0 commit comments

Comments
 (0)
Please sign in to comment.