fix: add error-handler type to manifest (#1933)
This commit is contained in:
@@ -6,7 +6,8 @@
|
|||||||
"www": "deno task --cwd=www start",
|
"www": "deno task --cwd=www start",
|
||||||
"screenshot": "deno run -A www/utils/screenshot.ts",
|
"screenshot": "deno run -A www/utils/screenshot.ts",
|
||||||
"check:types": "deno check **/*.ts && deno check **/*.tsx",
|
"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": [
|
"exclude": [
|
||||||
"**/_fresh/*",
|
"**/_fresh/*",
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ export async function getServerContext(opts: InternalFreshConfig) {
|
|||||||
if (!url.startsWith(baseUrl + "routes")) {
|
if (!url.startsWith(baseUrl + "routes")) {
|
||||||
throw new TypeError("Page is not a child of the basepath.");
|
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 baseRoute = path.substring(1, path.length - extname(path).length);
|
||||||
const name = baseRoute.replace("/", "-");
|
const name = baseRoute.replace("/", "-");
|
||||||
const isLayout = path.endsWith("/_layout.tsx") ||
|
const isLayout = path.endsWith("/_layout.tsx") ||
|
||||||
|
|||||||
+8
-3
@@ -74,9 +74,14 @@ export interface Manifest {
|
|||||||
ctx: any,
|
ctx: any,
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
) => Promise<any | Response> | any;
|
) => Promise<any | Response> | any;
|
||||||
// deno-lint-ignore no-explicit-any
|
handler?:
|
||||||
handler?: Handler<any, any> | Handlers<any, any> | UnknownHandler;
|
// deno-lint-ignore no-explicit-any
|
||||||
config?: RouteConfig | LayoutConfig | ErrorHandler;
|
| Handler<any, any>
|
||||||
|
// deno-lint-ignore no-explicit-any
|
||||||
|
| Handlers<any, any>
|
||||||
|
| UnknownHandler
|
||||||
|
| ErrorHandler;
|
||||||
|
config?: RouteConfig | LayoutConfig;
|
||||||
} | MiddlewareModule
|
} | MiddlewareModule
|
||||||
>;
|
>;
|
||||||
islands: Record<string, IslandModule>;
|
islands: Record<string, IslandModule>;
|
||||||
|
|||||||
@@ -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) {
|
export default function Error500Page({ error }: ErrorPageProps) {
|
||||||
return <p class="custom-500">Custom 500: {(error as Error).message}</p>;
|
return <p class="custom-500">Custom 500: {(error as Error).message}</p>;
|
||||||
|
|||||||
Reference in New Issue
Block a user