forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits

route-error.tsx23 lines, 1.1 KiBHistoryRawDownload
1import type { ErrorComponentProps } from "@tanstack/solid-router";
2import { PageLoadError } from "@/components/layout/page-load-error";
3import { RecordNotFound } from "@/components/layout/record-not-found";
4import { isNotFoundError } from "@/lib/record-list-path";
5
6/**
7 * The router's default error component: a page that throws while rendering
8 * (typically a failed list read through `resource.latest`) shows this in
9 * place of its own content, inside the shell, so navigation keeps working.
10 * Without it the throw reached the app-wide boundary and replaced everything
11 * with a full-screen 500.
12 *
13 * It can also render for the root route, above the i18n provider, so its
14 * text comes from `pageStateText` instead of `useT()`.
15 */
16export function RouteErrorFallback(props: ErrorComponentProps) {
17 // A missing record is an answer, not a failure: retrying a 404 changes nothing.
18 if (isNotFoundError(props.error)) {
19 return <RecordNotFound />;
20 }
21 console.error("Route render error:", props.error);
22 return <PageLoadError error={props.error} reset={props.reset} />;
23}