{"draft":null,"from":48,"to":318,"files":[{"path":"client/test/error-sentence.test.ts","added":30,"removed":0,"diff":"--- /dev/null\n+++ b/client/test/error-sentence.test.ts\n@@ -0,0 +1,30 @@\n+// errorSentence: what an error answer says, from JSON or from the host's HTML error page.\n+\n+import assert from \"node:assert/strict\";\n+import { test } from \"node:test\";\n+import { errorSentence } from \"../src/api-error.ts\";\n+\n+test(\"a JSON answer gives its error, else its reason\", () => {\n+\tassert.equal(errorSentence('{\"error\":\"no such draft\"}'), \"no such draft\");\n+\tassert.equal(errorSentence('{\"reason\":\"paused\"}'), \"paused\");\n+\tassert.equal(errorSentence(\"plain words\"), \"plain words\");\n+});\n+\n+test(\"an HTML error page is said by its title and Ray ID, not its first lines\", () => {\n+\tconst page = `<!DOCTYPE html>\n+<!--[if lt IE 7]> <html class=\"no-js ie6 oldie\" lang=\"en-US\"> <![endif]-->\n+<head>\n+<title>Worker threw exception | example.workers.dev | Cloudflare</title>\n+</head>\n+<body>${\"<div></div>\\n\".repeat(50)}\n+<span>Cloudflare Ray ID: <strong class=\"font-semibold\">8c1f2e3d4a5b6c7d</strong></span>\n+</body></html>`;\n+\tassert.equal(\n+\t\terrorSentence(page),\n+\t\t'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',\n+\t);\n+\tassert.equal(\n+\t\terrorSentence(\"<html><body>oops</body></html>\"),\n+\t\t\"an HTML error page, not the server's own answer: the server failed before it could say why\",\n+\t);\n+});"}],"unmatched":[]}