-
Notifications
You must be signed in to change notification settings - Fork 280
/
index.tsx
40 lines (33 loc) · 938 Bytes
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import {type ErrorBoundaryComponent} from '@shopify/remix-oxygen';
import {useCatch, useRouteError, isRouteErrorResponse} from '@remix-run/react';
export default function Index() {
return (
<p>
Edit this route in <em>app/routes/index.tsx</em>.
</p>
);
}
export const ErrorBoundaryV1: ErrorBoundaryComponent = ({error}) => {
console.error(error);
return <div>There was an error.</div>;
};
export function CatchBoundary() {
const caught = useCatch();
console.error(caught);
return (
<div>
There was an error. Status: {caught.status}. Message:{' '}
{caught.data?.message}
</div>
);
}
export function ErrorBoundary() {
const error = useRouteError();
if (isRouteErrorResponse(error)) {
console.error(error.status, error.statusText, error.data);
return <div>Route Error</div>;
} else {
console.error((error as Error).message);
return <div>Thrown Error</div>;
}
}