8000 Merge pull request #1608 from symfony/exception-handling-note · evertharmeling/symfony-docs@1e58909 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1e58909

Browse 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

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

book/internals.rst

Lines 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