Public: anyone can read this; the crew can change it.
A 404 and a 500 page say in plain words what happened and the one next step #15113
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15086-a-404-and-a-500-page-say-in-plain-words → main 4 commits fork 3 threads · 3 unresolved
3 files
changed +19
−1
src/web/failed_page.ts +2 −1
| @@ -60,7 +60,8 @@ export function failedPage(request: Request, pathname: string, id: string): Resp | ||
| 60 | 60 | </header> |
| 61 | 61 | <main class="shell" id="main"> |
| 62 | 62 | <div class="page-head"><h1>Something broke on our side. Reference: <code>${id}</code></h1></div> |
| 63 | <p class="actions">${btn("Try again", { href: retryTarget(request, pathname), variant: "primary" })}</p> | |
| 63 | <p class="muted">This is the forge's fault, not yours. <a href="/tell">Tell the crew</a> and quote the reference.</p> | |
| 64 | <p class="actions">${btn("Try again", { href: retryTarget(request, pathname), variant: "primary" })} ${btn("Go home", { href: "/" })}</p> | |
| 64 | 65 | </main>`; |
outdated
Principle 1: this second muted line repeats what the heading already says (Reference: id). Fold it into the sentence above, e.g. 'Quote the reference when you tell the crew.' replacing the duplicate sentence. Also three buttons in a row on a 360px phone will wrap; check it and keep one primary. |
||
| 65 | 66 | const text = `<!doctype html><html lang="en"><head><meta charset="utf-8" /> |
| 66 | 67 | <meta name="viewport" content="width=device-width, initial-scale=1" /> |
test/error-page-500.test.ts +3
| @@ -55,6 +55,9 @@ test("a throwing page answers 500 with chrome, the way back and an id found in t | ||
| 55 | 55 | expect(body).toContain('class="crumbs"'); |
| 56 | 56 | expect(body).toContain('href="/ada/notes"'); // the parent |
| 57 | 57 | expect(body).toContain("Try again"); |
| 58 | expect(body).toContain("the forge's fault"); | |
| 59 | expect(body).toContain('href="/tell"'); | |
| 60 | expect(body).toContain('href="/"'); | |
| 58 | 61 | expect(body).not.toContain("Go up one level"); |
| 59 | 62 | expect(body).not.toContain("<details"); |
| 60 | 63 | const id = /<code>([0-9a-f]{8})<\/code>/.exec(body)?.[1]; |
test/not-found-way-on.test.ts +14
| @@ -65,3 +65,17 @@ test("the 404 says one sentence, offers home and sign in (back here, when signed | ||
| 65 | 65 | expect(res.headers.get("x-request-id")).toBe(id!); |
| 66 | 66 | for (const h of ["content-security-policy", "x-content-type-options", "referrer-policy"]) expect(res.headers.get(h)).toBeTruthy(); |
| 67 | 67 | }); |
| 68 | ||
| 69 | test("the 404 names the path and links home and Explore; the API's 404 stays JSON", async () => { | |
| 70 | const res = await fetch(servers.url + "/nope/nothing", { headers: { accept: "text/html" } }); | |
| 71 | expect(res.status).toBe(404); | |
| 72 | const m = main(await res.text()); | |
| 73 | expect(m).toContain("<code>/nope/nothing</code>"); | |
| 74 | expect(m).toContain('href="/"'); | |
| 75 | expect(m).toContain('href="/explore"'); | |
| 76 | expect(m.match(/class="btn/g)?.length).toBe(2); | |
| 77 | const api = await fetch(servers.url + "/api/v1/nothing-here"); | |
| 78 | expect(api.status).toBe(404); | |
| 79 | expect(api.headers.get("content-type")).toStartWith("application/json"); | |
| 80 | expect(((await api.json()) as { error: string }).error).toBe("no_route"); | |
| 81 | }); |
new above
offline
Principle 8 and 1: say it once. 'This is the forge's fault, not yours. Nothing you did caused it.' says the same thing twice; keep the first sentence.