fix: Use custom 500 page for *all* handlers if present (#1362)

This commit is contained in:
Kamil Ogórek
2023-06-27 11:05:05 +02:00
committed by GitHub
parent ee3e4a1145
commit aff31c0f15
8 changed files with 108 additions and 1 deletions
+13
View File
@@ -0,0 +1,13 @@
{
"lock": false,
"imports": {
"$fresh/": "../../",
"preact": "https://esm.sh/preact@10.15.1",
"preact/": "https://esm.sh/preact@10.15.1/",
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.1.0"
},
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
}
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/
import dev from "$fresh/dev.ts";
await dev(import.meta.url, "./main.ts");
+17
View File
@@ -0,0 +1,17 @@
// DO NOT EDIT. This file is generated by fresh.
// This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`.
import * as $0 from "./routes/_500.tsx";
import * as $1 from "./routes/index.tsx";
const manifest = {
routes: {
"./routes/_500.tsx": $0,
"./routes/index.tsx": $1,
},
islands: {},
baseUrl: import.meta.url,
};
export default manifest;
+10
View File
@@ -0,0 +1,10 @@
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
await start(manifest);
+5
View File
@@ -0,0 +1,5 @@
import { ErrorPageProps } from "../../../server.ts";
export default function Error500Page({ error }: ErrorPageProps) {
return <p class="custom-500">Custom 500: {(error as Error).message}</p>;
}
@@ -0,0 +1,7 @@
import { Handlers } from "../../../server.ts";
export const handler: Handlers = {
GET(_req, ctx) {
throw new Error("Pickle Rick!");
},
};