import * as React from "react" import { useRouteError } from "react-router-dom" import { Button } from "@/components/ui/button" import { useProductDashboardHref } from "@/contexts/product-route-sync" import { isChunkLoadError } from "@/lib/chunk-load-error" /** * Route-level error surface, healthcare-flavored to match `_not-found.tsx`. * * - Eyebrow: human label, never raw status code. * - Illustration: clinical clipboard with a "needs attention" flag * (mirror of the 404 missing-entry illustration so the two pages * read as a coherent set). * - Headline (Ivy Presto italic): a calm clinical idiom. * - Substantial primary CTA + ghost dashboard link. * - Stack trace tucked into a `
` in dev only. */ function routeErrorFromUnknown(error: unknown): Error { if (error instanceof Error) return error if (typeof error === "object" && error !== null && "message" in error) { return new Error(String((error as { message: unknown }).message)) } return new Error(String(error)) } export function RouteError() { const dashboardHref = useProductDashboardHref() const routeError = useRouteError() const err = routeErrorFromUnknown(routeError) const chunkStale = isChunkLoadError(err) React.useEffect(() => { if (import.meta.env.DEV) { console.error(err) } }, [err]) const kicker = chunkStale ? "Update available" : "Something needs a second look" const title = chunkStale ? "Catching up." : "Let's run that again." const body = chunkStale ? "A newer version is ready. A reload picks it up — takes about a second." : import.meta.env.DEV ? err.message : "Something didn't render correctly. Reloading the page usually clears it." return (

{kicker}

{title}

{body}