Description
Symfony version(s) affected
5.4.0
Description
@lyrixx added a way to configure the status code of an exception (in #42244). When configuring the status code of an exception, the HTTP status code of the response is set as expected. However, the rendered HTML template does not seem to take the configured status code in account and Symfony will render the template as if the status code was not set.
How to reproduce
Use the config:
framework:
exceptions:
Doctrine\ORM\EntityNotFoundException:
status_code: 404
Then throw an EntityNotFoundException
. The HTTP status code will be 404, but the rendered template (both in the debug exception template and the production template) will show 500 Internal Server Error.
Possible Solution
Maybe the exceptions Mapping should also be used in the Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer
?
Additional Context
The status code of Symfony\Component\ErrorHandler\Exception\FlattenException::createFromThrowable
is used.