-
Notifications
You must be signed in to change notification settings - Fork 22k
Create MissingExactTemplate exception with separate template #29286
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
Create MissingExactTemplate exception with separate template #29286
Conversation
|
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @schneems (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review. Please see the contribution instructions for more information. |
matthewd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking about the right shape 👍🏻
Still need this bit:
Turn the long exception message into a custom HTML template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inherit from UnknownFormat, so the new exception is still rescued by anything that currently matches it
|
@matthewd Thanks for reviewing the PR. I addressed your comment about the inheritance and fixed the respective tests. Although I must say I don't quite understand the bit about turning the message into an html template. Is the entire message moving to a template? Will the exception not use it for instantiation anymore? Sorry, not really sure what is expected on this portion. |
|
@vinistock try triggering the exception in a newly generated Rails 5.1 app. Notice how the exception is just blurted out as one big chunk of text? We want to do better. We want the custom template to communicate what the exception means better than what the one paragraph exception message can do. To "show" rather than "tell". The existing exception message can be a spring board, but you can almost do with it as you please, it's not required for instantiation anymore (that's not fully true, but lets get the template going first then we can hone details). |
|
@kaspth I've customized the template a bit and changed the message. I also added what the expected path for the template would be, I thought that would make the exception cause more obvious to the user. Let me know if this is aligned with the expectations and if the exception messages / explanations are as descriptive and concise as they should be. The layout remains similar to the majority of Rails error pages. If any changes concerning this are wanted, give me a heads up. |
0b3944c to
e069e26
Compare
matthewd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I spectacularly dropped the ball on this 😟
I've added a few small notes, but this seems to be just about good to go. I haven't yet actually caused the error locally to see the resulting page, but the HTML sounds good! (If you happen to have it open locally and can add a screenshot, that'd be awesome; if not, that's fine too.)
Sorry again I left this unanswered for so long!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting idea, but making a more accurate guess is a lot harder than this, so I think it's best to leave it off for now. (Notably, it has checked a lot more than one filename.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a trailing comma, so this line doesn't have to change next time we add an entry.
Also, I think we need to add our new exception to rescue_responses above as well (pointing to :not_acceptable, same as the existing UnknownFormat)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"exact" sounds a bit odd in a user-facing context here. How about we title it "No template for interactive request"?
4c6c334 to
76d79e7
Compare
|
@matthewd I've addressed your comments and rebased with the current master. Let me know if any other changes are needed. Here's the screenshot of a sample application raising the error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why we need to define an initialize?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we can keep the raise ActionController::MissingExactTemplate, message pattern here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we align all other values or maybe a next PR un-align all the values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if the source and the trace is going to be useful for this exception. The source is always inside Rails. I'd also remove the request_and_response. This page is more informative than actually an application error.
|
@rafaelfranca Thanks for the review. I believe all your comments make sense and applied all the requested changes. Let me know if there's anything else to be done. |
rafaelfranca
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Can you squash your commits?
e4c7954 to
297a579
Compare
|
@rafaelfranca all done. |
…e_exception Create MissingExactTemplate exception with separate template
Changes the Getting Started guide explanation for `ActionController::MissingExactTemplate` error, to reflect the current message. Follow up for rails#29286, rails#35148 [ci skip]

This PR is supposed to address issue #29280.
Create new exception class MissingExactTemplate with it's own HTML template and raise it in the implicit_render class.
This is my first contribution, so please let me know if I'm missing something or if I'm breaking any code style standards.