Skip to content

Changing the status code of an exception isn't possible #2250

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lgv5
Copy link

@lgv5 lgv5 commented Apr 26, 2025

Summary

Remove the paragraph stating that the status code of a reply->exception can be changed. Amend the "Also" at the beginning of the next paragraph.

Motivation

Bashed my head too many times trying to understand why $self->reply->exception->rendered(400) was returning an HTTP 500 status code. It isn't possible.

References

IRC chat.

16:56 < Lucas_> question: https://docs.mojolicious.org/Mojolicious/Guides/Rendering#Rendering-exception-and-not_found-pages says that I can change the status code of an 
    exception with ->rendered, but that isn't working. Tried both Mojolicious 9.37 and 9.39
16:56 < Lucas_> there is also an issue, https://github.com/mojolicious/mojo/issues/1014 , which says it won't be supported
16:57 < Lucas_> so, which one is it?
17:26 < kraih> The docs are wrong

@kraih kraih requested review from a team, marcusramberg, kraih, christopherraa and Grinnz April 26, 2025 19:03
kraih
kraih previously approved these changes Apr 26, 2025
return $c->reply->exception('Division by zero!')->rendered(400) if $divisor == 0;

You can also change the templates of those pages, since you most likely want to show your users something more closely
To change the templates of those pages, since you most likely want to show your users something more closely
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a sentence fragment; better would be just saying "You can change..." without "also".

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, that reads way better.

@lgv5 lgv5 force-pushed the rendering-guide-fix branch from 1fc6241 to 484e27f Compare April 26, 2025 20:07
@lgv5 lgv5 requested a review from Grinnz April 26, 2025 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants