feat: give the error page a way onward - #631
Merged
Merged
Conversation
The error page said what went wrong and nothing else: no link home, no way back to what the user was doing, and no hint of who could act on it. An ErrorPage.Kind, set through a new "kind" page parameter next to the existing message, now carries the shape of the response around those details: whether the address is the asking user's to correct, the published nanopublication its author's, or the malfunction Nanodash's own. It decides what the page says about who can act, whether it offers a way to report the problem, and the HTTP status it is answered with, so that clients other than browsers can tell these apart too. Every error page now links home and, where the referrer is one of this instance's own pages, back to where the user was. The ones that are ours also offer a pre-filled issue on the tracker, carrying what the user saw, the failing address, and the version, so a malfunction doesn't dead-end at a stack trace in the server log. Callers say which kind they ran into: a malformed nanopublication identifier is a request to correct, and a query that can't be loaded is its author's to fix unless the ID held no artifact code at all. Without a kind, the page falls back to the status the container settled on (that is how web.xml's /error/404 and /error/500 arrive), and to a malfunction otherwise, since an error nobody foresaw usually is one. Closes #616 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
🎉 This PR is included in version 5.12.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #616.
ErrorPagesaid what went wrong and nothing else — no link home, no way back to what the user was doing, no hint of who could act on it. CompareNanopubNotFoundPage, which explains the situation, offers a retry and a link home, and answers with a fitting HTTP status.The shape of the error, not just its details
A new
ErrorPage.Kind, set through akindpage parameter next to the existingmessage, says whose problem it is. It decides what the page tells the user to do, whether it offers a way to report the problem, and the status it is answered with:REQUESTNOT_FOUNDCONTENTMALFUNCTIONconfigureResponse()answers with the matching status the wayNanopubNotFoundPagedoes, so non-browser clients can tell these apart too. Without a kind, the page falls back to the status the servlet container settled on — that is howweb.xml's/error/404and/error/500arrive — and toMALFUNCTIONotherwise, since an error nobody foresaw usually is one.A way onward
Refererand accepted only for this instance's own pages — an off-site referrer is not where they were working — and never for an error page itself, which would only loop.Callers say what they ran into
NanopubNotFoundPage.forwardFor()marks a malformed identifier as the asking user's to correct.GrlcQueryclassifies a failed load — the asking user's when the ID holds no artifact code at all, so nothing could have been fetched for it, and the query author's otherwise — and passes it throughQueryLoadException.getKind()toQueryPage.Tests
11 tests in
ErrorPageTestcover the per-kind wording and status, the report link's presence and contents, the back-link's accept and reject cases, and the container-status takeover. Kind assertions were added toGrlcQueryTest,QueryPageTest, andNanopubNotFoundPageTest. Full suite green: 1134 tests, 0 failures.🤖 Generated with Claude Code