{"draft":null,"from":37,"to":318,"files":[{"path":"client/src/api-error.ts","added":14,"removed":1,"diff":"--- a/client/src/api-error.ts\n+++ b/client/src/api-error.ts\n@@ -36,7 +36,10 @@\n \t);\n }\n \n-/** The server's `{error: \"sentence\"}` answer, or the start of whatever it sent. */\n+/**\n+ * The server's `{error: \"sentence\"}` answer, or the start of whatever it sent. An HTML page (the host's error\n+ * page, when the server itself failed) is said by its title and Ray ID, which its first lines never reach.\n+ */\n export function errorSentence(body: string): string {\n \ttry {\n \t\tconst parsed = JSON.parse(body) as { error?: unknown; reason?: unknown };\n@@ -45,5 +48,15 @@\n \t} catch {\n \t\t// Not JSON.\n \t}\n+\tif (/^\\s*<(!doctype html|html)/i.test(body)) {\n+\t\tconst plain = (s: string) =>\n+\t\t\ts\n+\t\t\t\t.replace(/<[^>]*>/g, \" \")\n+\t\t\t\t.replace(/\\s+/g, \" \")\n+\t\t\t\t.trim();\n+\t\tconst title = plain(/<title>([\\s\\S]*?)<\\/title>/i.exec(body)?.[1] ?? \"\");\n+\t\tconst ray = /Ray ID:\\s*(?:<[^>]*>\\s*)*([0-9a-f]+)/i.exec(body)?.[1];\n+\t\treturn `an HTML error page${title !== \"\" ? ` titled ${JSON.stringify(title)}` : \"\"}${ray ? ` (Ray ID ${ray})` : \"\"}, not the server's own answer: the server failed before it could say why`;\n+\t}\n \treturn body.slice(0, 300);\n }"}],"unmatched":[]}