Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configure error page #132

Merged
merged 4 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions src/app/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,35 @@

import { useEffect } from 'react';

export default function Error({ error, reset }: { error: Error; reset: () => void }) {
import { CustomButton } from '@/components/Buttons/CustomButton';
import { Topbar } from '@/components/Topbar/Topbar';

export default function Error({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) {
useEffect(() => {
// Log the error to an error reporting service
/* eslint-disable no-console */
console.error(error);
}, [error]);

return (
<div>
<h2>Something went wrong!</h2>
<button
type="button"
onClick={
// Attempt to recover by trying to re-render the segment
() => reset()
}
>
Try again
</button>
<div className="flex flex-col h-screen">
<Topbar />
<main className="flex h-full flex-col items-center justify-center gap-2 text-content">
<section className="text-center">
<h2 className="text-xl font-semibold">An Error Occurred</h2>
<p>Please try again or go back to the Home page.</p>
</section>
<div className="flex flex-row gap-2 mt-4">
<CustomButton variant="solid" size="lg" onClick={() => reset()}>
Try again
</CustomButton>
<a href="/">
<CustomButton variant="solid" size="lg">
Go to Home page
</CustomButton>
</a>
</div>
</main>
</div>
);
}
25 changes: 25 additions & 0 deletions src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use client';

import { CustomButton } from '@/components/Buttons/CustomButton';
import { Topbar } from '@/components/Topbar/Topbar';

export default function NotFound() {
return (
<div className="flex flex-col h-screen">
<Topbar />
<main className="flex h-full flex-col items-center justify-center gap-2 text-content">
<section className="text-center">
<h2 className="text-xl font-semibold">Ooops</h2>
<p>The requested page could not be found.</p>
</section>
<div className="flex flex-row gap-2 mt-4">
<a href="/">
<CustomButton variant="solid" size="lg">
Go to Home page
</CustomButton>
</a>
</div>
</main>
</div>
);
}
Loading