diff --git a/src/worker/error.ts b/src/worker/error.ts index 81405b1..dddf830 100644 --- a/src/worker/error.ts +++ b/src/worker/error.ts @@ -1,6 +1,6 @@ export function errorTemplate(trace: string, fetchedURL: string) { - // turn script into a data URI so we don"t have to escape any HTML values - const script = ` + // turn script into a data URI so we don"t have to escape any HTML values + const script = ` errorTrace.value = ${JSON.stringify(trace)}; fetchedURL.textContent = ${JSON.stringify(fetchedURL)}; for (const node of document.querySelectorAll("#hostname")) node.textContent = ${JSON.stringify(location.hostname)}; @@ -8,54 +8,236 @@ export function errorTemplate(trace: string, fetchedURL: string) { version.textContent = ${JSON.stringify(VERSION)}; `; - return ` - -
+ return ` + +Failed to load
-Internal Server Error
- -Try:
-If you"re the administrator of , try:
-Scramjet v
+ + + +There was an error loading
+ + +Try:
+If you're the administrator of , try:
+Scramjet v
+ - - + + + `; } export function renderError(err: unknown, fetchedURL: string) { - const headers = { - "content-type": "text/html", - }; - if (crossOriginIsolated) { - headers["Cross-Origin-Embedder-Policy"] = "require-corp"; - } + const headers = { + "content-type": "text/html", + }; + if (crossOriginIsolated) { + headers["Cross-Origin-Embedder-Policy"] = "require-corp"; + } - return new Response(errorTemplate(String(err), fetchedURL), { - status: 500, - headers: headers, - }); + return new Response(errorTemplate(String(err), fetchedURL), { + status: 500, + headers: headers, + }); }