A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
feat(router): add global error boundary for route errors
Oumar Mimounif42b29e4ac0e
diff --git a/apps/client/src/pages/public/error.tsx b/apps/client/src/pages/public/error.tsxnew file mode 100644index 000000000..f1158e89f--- /dev/null+++ b/apps/client/src/pages/public/error.tsx@@ -0,0 +1,41 @@+import { useRouteError } from "react-router";+import { Button } from "@reactive-resume/ui";++type RouterError = {+ status: number;+ statusText?: string;+ data: string;+ message?: string;+} & Error;++export const ErrorPage = () => {+ const error = useRouteError() as RouterError;++ return (+ <main className="flex items-center justify-center min-h-screen p-4">+ <div className="w-full max-w-sm space-y-6">+ <h4 className="flex flex-col text-4xl font-bold text-white">+ <span>+ Error {error.status}+ </span>+ {error.statusText && <span className="text-base font-normal">{error.statusText}</span>}+ </h4>++ <p className="text-sm text-gray-500 break-words">+ {error.data || error.message}+ </p>++ <div className="pt-2">+ <a+ href={process.env.PUBLIC_URL}+ className="inline-block"+ >+ <Button>+ Go to home+ </Button>+ </a>+ </div>+ </div>+ </main>+ );+};diff --git a/apps/client/src/router/index.tsx b/apps/client/src/router/index.tsxindex ea6496570..99fd390cf 100644--- a/apps/client/src/router/index.tsx+++ b/apps/client/src/router/index.tsx@@ -20,9 +20,10 @@ import { Providers } from "../providers";import { AuthGuard } from "./guards/auth";import { GuestGuard } from "./guards/guest";import { authLoader } from "./loaders/auth";+import { ErrorPage } from "../pages/public/error";export const routes = createRoutesFromElements(- <Route element={<Providers />}>+ <Route element={<Providers />} errorElement={<ErrorPage />}><Route element={<HomeLayout />}><Route path="/" element={<HomePage />} /></Route>