diff --git a/www/routes/_500.tsx b/www/routes/_500.tsx deleted file mode 100644 index 8bd82eb0..00000000 --- a/www/routes/_500.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { ServerCodePage } from "./_404.tsx"; - -export default function InternalServerError() { - return ServerCodePage({ - serverCode: 500, - codeDescription: "Oops! Something went wrong.", - }); -} diff --git a/www/routes/_404.tsx b/www/routes/_error.tsx similarity index 63% rename from www/routes/_404.tsx rename to www/routes/_error.tsx index 596c5550..12e433ef 100644 --- a/www/routes/_404.tsx +++ b/www/routes/_error.tsx @@ -1,3 +1,4 @@ +import { HttpError, type PageProps } from "@fresh/core"; import LemonDrop from "../islands/LemonDrop.tsx"; export function ServerCodePage( @@ -27,9 +28,19 @@ export function ServerCodePage( ); } -export default function PageNotFound() { +export default function PageNotFound(props: PageProps) { + const error = props.error; + if (error instanceof HttpError) { + if (error.status === 404) { + return ServerCodePage({ + serverCode: 404, + codeDescription: "Couldn’t find what you’re looking for.", + }); + } + } + return ServerCodePage({ - serverCode: 404, - codeDescription: "Couldn’t find what you’re looking for.", + serverCode: 500, + codeDescription: "Oops! Something went wrong.", }); }