Skip to content

Commit 5690fa1

Browse files
Merge pull request #338 from ekumamatthew/error-page
feat: added error page
2 parents f09b95e + 5ca4c4f commit 5690fa1

4 files changed

Lines changed: 76 additions & 1 deletion

File tree

frontend/app/error.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"use client";
2+
3+
import { useEffect } from "react";
4+
5+
interface ErrorPageProps {
6+
error: Error & { digest?: string };
7+
reset: () => void;
8+
}
9+
10+
export default function ErrorPage({ error, reset }: ErrorPageProps) {
11+
useEffect(() => {
12+
// Log the error to an error reporting service
13+
console.error(error);
14+
}, [error]);
15+
16+
return (
17+
<div className="min-h-screen bg-slate-900">
18+
<div className="h-screen max-w-2xl mx-auto p-4 flex flex-col items-center justify-center">
19+
<div className="flex items-center justify-center mb-6">
20+
<h1 className="text-4xl text-white mr-2">500 |</h1>
21+
<p className="text-lg text-white">Internal Server Error</p>
22+
</div>
23+
24+
<p className="text-sm text-white">
25+
We&apos;re having trouble right now. Please refresh the page or try again
26+
later.
27+
</p>
28+
<div className="flex lg:flex-row flex-col max-w-md my-4 gap-4">
29+
<button
30+
onClick={reset}
31+
className="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700"
32+
>
33+
Try Again
34+
</button>
35+
<button
36+
onClick={() => (window.location.href = "/")}
37+
className="px-4 py-2 bg-slate-600 text-white rounded hover:bg-slate-700"
38+
>
39+
Go Home
40+
</button>
41+
</div>
42+
</div>
43+
</div>
44+
);
45+
}

frontend/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ export default function Home() {
44
<h1>HomePage</h1>
55
</section>
66
);
7-
}
7+
}

frontend/app/test-error/page.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"use client";
2+
3+
import { useState } from "react";
4+
5+
export default function TestErrorPage() {
6+
const [shouldThrow, setShouldThrow] = useState(false);
7+
8+
if (shouldThrow) {
9+
throw new Error("This is a test error to demonstrate the error page!");
10+
}
11+
12+
return (
13+
<div className="min-h-screen bg-slate-900 text-white p-8">
14+
<div className="max-w-2xl mx-auto">
15+
<h1 className="text-3xl font-bold mb-6">Error Page Test</h1>
16+
<p className="text-lg mb-6">
17+
Click the button below to trigger an error and test the error page:
18+
</p>
19+
<button
20+
onClick={() => setShouldThrow(true)}
21+
className="px-6 py-3 bg-red-600 hover:bg-red-700 text-white font-medium rounded-lg transition-colors duration-200"
22+
>
23+
Trigger Error
24+
</button>
25+
</div>
26+
</div>
27+
);
28+
}

frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"test": "jest"
1111
},
1212
"dependencies": {
13+
"@tanstack/react-query": "^5.90.2",
14+
"@tanstack/react-query-devtools": "^5.90.2",
1315
"next": "15.5.4",
1416
"react": "19.1.0",
1517
"react-dom": "19.1.0"

0 commit comments

Comments
 (0)