- MCP
- blame on this site's /mcp
- CLI
- abso blame client/test/error-sentence.test.ts --json
- JSON
- /christopher/abso-core/blame/client/test/error-sentence.test.ts?format=json
30 linespinch 100%Last change pinch in version 49,
30 lines from 1 change in 1 version.
pinch49Errors: say an HTML error page by its title and Ray ID
When the server fails before it can answer, its host sends an HTML error page instead. The client printed the page's first 300 characters, which are all doctype and IE comments, so nobody could tell what had failed: "GET /a/me/status answered 500: <!DOCTYPE html> <!--[if lt IE 7]> ...".
Now an HTML answer reads: answered 500: an HTML error page titled "Worker threw exception | ... | Cloudflare" (Ray ID ...), not the server's own answer: the server failed before it could say why. The title and Ray ID are what an operator needs to find the failure. JSON answers and plain text are said as before. Tested in error-sentence.test.ts.Compare1// errorSentence: what an error answer says, from JSON or from the host's HTML error page.
3import assert from "node:assert/strict";
4import { test } from "node:test";
5import { errorSentence } from "../src/api-error.ts";
7test("a JSON answer gives its error, else its reason", () => {
8 assert.equal(errorSentence('{"error":"no such draft"}'), "no such draft");
9 assert.equal(errorSentence('{"reason":"paused"}'), "paused");
10 assert.equal(errorSentence("plain words"), "plain words");
11});
13test("an HTML error page is said by its title and Ray ID, not its first lines", () => {
14 const page = `<!DOCTYPE html>
15<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
16<head>
17<title>Worker threw exception | example.workers.dev | Cloudflare</title>
18</head>
19<body>${"<div></div>\n".repeat(50)}
20<span>Cloudflare Ray ID: <strong class="font-semibold">8c1f2e3d4a5b6c7d</strong></span>
21</body></html>`;
22 assert.equal(
23 errorSentence(page),
24 'an HTML error page titled "Worker threw exception | example.workers.dev | Cloudflare" (Ray ID 8c1f2e3d4a5b6c7d), not the server\'s own answer: the server failed before it could say why',
25 );
26 assert.equal(
27 errorSentence("<html><body>oops</body></html>"),
28 "an HTML error page, not the server's own answer: the server failed before it could say why",
29 );
30});