Skip to content

Commit 89509a7

Browse files
committed
.
1 parent f82be25 commit 89509a7

File tree

4 files changed

+34
-38
lines changed

4 files changed

+34
-38
lines changed

src/app/catalog/error.tsx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,12 @@
11
"use client";
22

3-
import { useEffect } from "react";
4-
import { ErrorPage } from "@/components/error-page";
5-
import { Button } from "@/components/ui/button";
3+
import { RuntimeError } from "@/components/error-page";
64

75
interface ErrorProps {
86
error: Error & { digest?: string };
97
reset: () => void;
108
}
119

1210
export default function CatalogErrorPage({ error, reset }: ErrorProps) {
13-
useEffect(() => {
14-
console.error(error);
15-
}, [error]);
16-
17-
return (
18-
<ErrorPage
19-
title="Something went wrong"
20-
actions={
21-
<Button onClick={reset} variant="default">
22-
Try again
23-
</Button>
24-
}
25-
>
26-
An unexpected error occurred. Please try again.
27-
</ErrorPage>
28-
);
11+
return <RuntimeError error={error} reset={reset} />;
2912
}

src/app/error.tsx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,12 @@
11
"use client";
22

3-
import { useEffect } from "react";
4-
import { ErrorPage } from "@/components/error-page";
5-
import { Button } from "@/components/ui/button";
3+
import { RuntimeError } from "@/components/error-page";
64

75
interface ErrorProps {
86
error: Error & { digest?: string };
97
reset: () => void;
108
}
119

1210
export default function RootErrorPage({ error, reset }: ErrorProps) {
13-
useEffect(() => {
14-
console.error(error);
15-
}, [error]);
16-
17-
return (
18-
<ErrorPage
19-
title="Something went wrong"
20-
actions={
21-
<Button onClick={reset} variant="default">
22-
Try again
23-
</Button>
24-
}
25-
>
26-
An unexpected error occurred. Please try again.
27-
</ErrorPage>
28-
);
11+
return <RuntimeError error={error} reset={reset} />;
2912
}

src/components/error-page/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { ErrorPage } from "./error-page";
2+
export { RuntimeError } from "./runtime-error";
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"use client";
2+
3+
import { useEffect } from "react";
4+
import { Button } from "@/components/ui/button";
5+
import { ErrorPage } from "./error-page";
6+
7+
interface RuntimeErrorProps {
8+
error: Error & { digest?: string };
9+
reset: () => void;
10+
}
11+
12+
export function RuntimeError({ error, reset }: RuntimeErrorProps) {
13+
useEffect(() => {
14+
console.error(error);
15+
}, [error]);
16+
17+
return (
18+
<ErrorPage
19+
title="Something went wrong"
20+
actions={
21+
<Button onClick={reset} variant="default">
22+
Try again
23+
</Button>
24+
}
25+
>
26+
An unexpected error occurred. Please try again.
27+
</ErrorPage>
28+
);
29+
}

0 commit comments

Comments
 (0)