Files
sweet/src/server/default_error_page.ts
T
Luca Casonato b12867a582 feat: support JSX automatic mode (#610)
This commit adds support for JSX automatic mode instead of the default
mode that requires the presence of the JSX pragma in each file.

This commit also adds the config file to the `fresh.gen.ts` manifest,
which is used to determine if the client emit should use automatic mode.

The minimum Deno version has also been bumped to 1.25.0.
2022-08-26 11:03:00 +02:00

59 lines
1.2 KiB
TypeScript

import { h } from "preact";
import { DEBUG } from "./constants.ts";
import type { ErrorPageProps } from "./types.ts";
export default function DefaultErrorPage(props: ErrorPageProps) {
const { error } = props;
let message = undefined;
if (DEBUG) {
if (error instanceof Error) {
message = error.stack;
} else {
message = String(error);
}
}
return h(
"div",
{
style: {
display: "flex",
justifyContent: "center",
alignItems: "center",
},
},
h(
"div",
{
style: {
border: "#f3f4f6 2px solid",
borderTop: "red 4px solid",
background: "#f9fafb",
margin: 16,
minWidth: "300px",
width: "50%",
},
},
h("p", {
style: {
margin: 0,
fontSize: "12pt",
padding: 16,
fontFamily: "sans-serif",
},
}, "An error occured during route handling or page rendering."),
message && h("pre", {
style: {
margin: 0,
fontSize: "12pt",
overflowY: "auto",
padding: 16,
paddingTop: 0,
fontFamily: "monospace",
},
}, message),
),
);
}