Skip to content

Commit ecda51f

Browse files
committed
added a note about exception handling with a special status code
1 parent a1e1355 commit ecda51f

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)