-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] Wrong template is rendered when configuring an exception status code #44433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the feedback. I'll have a look this weekend |
We should also take care of |
What if we wrap the original exception (if it's mapped) into a Otherwise, even the custom error renderers will have to worry about this exception mapping strategy on their own to fix the response body info. |
Thanks for the idea, @yceruto . Let me think of it and try to do. But not sure if I should do it as a separate PR and then we select which one to merge? Just to have both ideas side-by-side. Give me some time, I'll try to come up with something and thanks for the idea! |
@yceruto That would be a breaking change. If any |
@GromNaN Yes, that's exactly what I meant :) and I think it's fine, the exception class is debugging information, and as we can see in the 2nd screenshot the original exception is still displayed, and it will also be included in the FlattenException as the previous exception. To be more accurate we could even create a specific HTTP exception for this mapping strategy, something like |
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:
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.The text was updated successfully, but these errors were encountered: