Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1e58909

Browse filesBrowse files
committed
Merge pull request symfony#1608 from symfony/exception-handling-note
added a note about exception handling with a special status code
2 parents a1e1355 + ecda51f commit 1e58909
Copy full SHA for 1e58909

File tree

Expand file treeCollapse file tree

1 file changed

+9
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-0
lines changed

‎book/internals.rst

Copy file name to clipboardExpand all lines: book/internals.rst
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,15 @@ and set a new ``Exception`` object, or do nothing:
377377
// $event->setException($exception);
378378
}
379379
380+
.. note::
381+
382+
As Symfony ensures that the Response status code is set to the most
383+
appropriate one depending on the exception, setting the status on the
384+
response won't work. If you want to overwrite the status code (which you
385+
should not without a good reason), set the ``X-Status-Code`` header::
386+
387+
return new Response('Error', 404 /* ignored */, array('X-Status-Code' => 200));
388+
380389
.. index::
381390
single: Event Dispatcher
382391

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.