fix: add error-handler type to manifest (#1933)

This commit is contained in:
Christian Svensson
2023-10-16 07:45:34 +02:00
committed by GitHub
parent 86a96eeee4
commit 206d5002d6
4 changed files with 16 additions and 6 deletions
+2 -1
View File
@@ -6,7 +6,8 @@
"www": "deno task --cwd=www start",
"screenshot": "deno run -A www/utils/screenshot.ts",
"check:types": "deno check **/*.ts && deno check **/*.tsx",
"ok": "deno fmt --check && deno lint && deno task check:types && deno task test"
"ok": "deno fmt --check && deno lint && deno task check:types && deno task test",
"install-puppeteer": "PUPPETEER_PRODUCT=chrome deno run -A --unstable https://deno.land/x/puppeteer@16.2.0/install.ts && PUPPETEER_PRODUCT=firefox deno run -A --unstable https://deno.land/x/puppeteer@16.2.0/install.ts"
},
"exclude": [
"**/_fresh/*",
+1 -1
View File
@@ -172,7 +172,7 @@ export async function getServerContext(opts: InternalFreshConfig) {
if (!url.startsWith(baseUrl + "routes")) {
throw new TypeError("Page is not a child of the basepath.");
}
const path = url.substring(baseUrl.length).substring("routes".length);
const path = url.substring(baseUrl.length + "routes".length);
const baseRoute = path.substring(1, path.length - extname(path).length);
const name = baseRoute.replace("/", "-");
const isLayout = path.endsWith("/_layout.tsx") ||
+8 -3
View File
@@ -74,9 +74,14 @@ export interface Manifest {
ctx: any,
// deno-lint-ignore no-explicit-any
) => Promise<any | Response> | any;
// deno-lint-ignore no-explicit-any
handler?: Handler<any, any> | Handlers<any, any> | UnknownHandler;
config?: RouteConfig | LayoutConfig | ErrorHandler;
handler?:
// deno-lint-ignore no-explicit-any
| Handler<any, any>
// deno-lint-ignore no-explicit-any
| Handlers<any, any>
| UnknownHandler
| ErrorHandler;
config?: RouteConfig | LayoutConfig;
} | MiddlewareModule
>;
islands: Record<string, IslandModule>;
+5 -1
View File
@@ -1,4 +1,8 @@
import { ErrorPageProps } from "../../../server.ts";
import { ErrorHandler, ErrorPageProps } from "../../../server.ts";
export const handler: ErrorHandler = (_req, ctx) => {
return ctx.render();
};
export default function Error500Page({ error }: ErrorPageProps) {
return <p class="custom-500">Custom 500: {(error as Error).message}</p>;