From 6d3e3ae986e362d941efbce69d2ba0fcf9e75d4a Mon Sep 17 00:00:00 2001 From: gnezim Date: Wed, 15 Apr 2026 00:35:05 +0300 Subject: [PATCH] Add error pages for 404, 500, 503 codes --- src/routes/error/[code]/page.tsx | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/routes/error/[code]/page.tsx diff --git a/src/routes/error/[code]/page.tsx b/src/routes/error/[code]/page.tsx new file mode 100644 index 00000000..1feb415f --- /dev/null +++ b/src/routes/error/[code]/page.tsx @@ -0,0 +1,55 @@ +import { useParams } from "@modern-js/runtime/router"; + +const ERROR_CONFIG: Record = { + "404": { + title: "Page not found", + description: + "The page you are looking for does not exist or the link is broken.", + }, + "500": { + title: "Server error", + description: + "An internal error occurred while processing your request. Please try again later.", + }, + "503": { + title: "Service unavailable", + description: + "The service is temporarily unavailable. Please try again in a few moments.", + }, +}; + +const FALLBACK = { + title: "Error", + description: "An unexpected error occurred.", +}; + +/** + * Error page for HTTP-like error codes (404, 500, 503). + * Simple text-based UI — no design system dependency yet. + * Route: /error/:code + */ +export default function ErrorPage(): JSX.Element { + const { code } = useParams<{ code: string }>(); + const config = (code ? ERROR_CONFIG[code] : undefined) ?? FALLBACK; + + return ( +
+

{code ?? "?"}

+

{config.title}

+

{config.description}

+ + Go to home page + +
+ ); +}