MCPcopy Create free account
hub / github.com/fontsource/fontsource / ErrorBoundary

Function ErrorBoundary

website/app/components/ErrorBoundary.tsx:6–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4import { IconGithub } from './icons/Github';
5
6export function ErrorBoundary() {
7 const error = useRouteError();
8
9 let status = 500;
10 let title = 'Something went wrong';
11 let description = 'An unexpected error occurred. Please try again.';
12
13 if (isRouteErrorResponse(error)) {
14 status = error.status;
15 title = status === 404 ? 'Page not found' : 'Server error';
16 description =
17 status === 404
18 ? "The page you're looking for doesn't exist."
19 : error.statusText || description;
20 } else if (error instanceof Error) {
21 description = error.message;
22 }
23
24 return (
25 <Center className={styles.container}>
26 <Flex align="center" className={styles.content} direction="column">
27 <Flex align="center" className={styles.errorInfo} direction="column">
28 <Text className={styles.statusCode}>{status}</Text>
29 <Title order={1} className={styles.title}>
30 {title}
31 </Title>
32 <Text className={styles.description}>{description}</Text>
33 </Flex>
34
35 <Stack className={styles.actions} gap={12}>
36 <Button
37 component={Link}
38 to="/"
39 size="md"
40 fullWidth
41 className={styles.primaryButton}
42 >
43 Go home
44 </Button>
45 <Button
46 component="a"
47 href="https://github.com/fontsource/fontsource/issues/new"
48 variant="outline"
49 size="md"
50 leftSection={<IconGithub height={16} />}
51 target="_blank"
52 rel="noopener noreferrer"
53 fullWidth
54 className={styles.outlineButton}
55 >
56 Report issue
57 </Button>
58 </Stack>
59
60 {process.env.NODE_ENV === 'development' && error instanceof Error && (
61 <div className={styles.devError}>
62 <Text className={styles.devErrorTitle}>Development Error</Text>
63 <Text className={styles.devErrorContent}>{error.stack}</Text>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected