-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Error handlers are hard to blend in with the rest of the site #222
Comments
Error catchers cannot fail. They are meant to catch, not handle errors. That is, they are a sink for errors that aren't handled elsewhere. If you need custom error handling, you can use forwarding and/or |
@SergioBenitez I think this confusion could be avoided in the future by a docs improvement. The fact that the section on Error Catchers in the docs does not link to the section on Errors (and vice versa) is what I think lead to this confusion. From the docs on Error Catchers
Is not entirely clear on what "wants to return an error page to the client" means from this page alone (the Errors doc page clarifies this). I think a link the Errors section or a short sentence elaborating on what "wants to return an error page to the client" means would make the docs easier to understand and tie the related concepts together. Thoughts? If 👍 I can open a PR for it later today. |
I see the reasoning behind this now, but what should I do in the case of 404 errors? Forwarding feels a bit like a hack and I don't know if it's going to have an effect on SEO/accessibility/etc. |
@echochamber You're totally right. The docs aren't in any repository yet, but feel free to write something up and submit it as a PR here; it'll force me to finally put the docs up somewhere. @LaylConway Most 404 pages don't make use of anything in the request except maybe the URL. As a result, error catchers should work well there. Nonetheless, you can invoke request guards directly from the error handler if needed. See, for instance, how to invoke the But it really all depends on why/when you're getting a 404. The simplest/most correct thing to do is is to return a |
Thank you for the answers, I'm leaving this open for the docs issue, feel free to close it if needed. |
Closing this out. @echochamber Feel free to open a PR when you're ready. If you want to chat about it, visit the #rocket IRC/Matrix channel. |
@SergioBenitez Apologies, I forgot about this over the weekend. Just remembered I offered to write some docs here. I'll have a PR for you tonight or tomorrow. |
From the docs:
This is problematic if your site includes for example a navigation bar with a signed in section. These kinds of sections in the site's layout shared between all pages still often need to touch the DB (or cached data) and cookies. Currently the error handler doesn't allow this being done easily. I feel like it would be best to treat error handlers as any other handler, except that they can also take Request and Error as parameters.
An alternative solution is to use a redirect, but that just works around the underlying issue.
The text was updated successfully, but these errors were encountered: