Skip to content

Commit

Permalink
feat: add error and not found page, provided by nextjs example
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-stumpf committed Nov 25, 2024
1 parent a9efaae commit b6c1d88
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/app/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"use client";

import { useEffect } from "react";

const ErrorBoundary = ({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) => {
useEffect(() => {
// Log the error to an error reporting service
console.error(error);
}, [error]);

return (
<div>
<h1>Something went wrong!</h1>
<button
type="button"
onClick={
// Attempt to recover by trying to re-render the segment
() => reset()
}
>
Try again
</button>
</div>
);
};

export default ErrorBoundary;
11 changes: 11 additions & 0 deletions src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Link from "next/link";

export default function NotFound() {
return (
<div>
<h1>Not Found</h1>
<p>Could not find requested resource</p>
<Link href="/">Return Home</Link>
</div>
);
}

0 comments on commit b6c1d88

Please sign in to comment.