diff --git a/app/error.tsx b/app/error.tsx new file mode 100644 index 000000000..4667ff618 --- /dev/null +++ b/app/error.tsx @@ -0,0 +1,125 @@ +'use client'; +import Link from 'next/link'; +import { useEffect } from 'react'; +import { toast } from 'sonner'; + +export default function ErrorBoundary({ + error, + reset, +}: { + error: Error & { digest?: string }; + reset: () => void; +}) { + useEffect(() => { + console.error(error); + }, [error]); + + const terminalContent = `git status + + fatal: Your branch and 'origin/main' have diverged, + and have 1 and 1 different commits each, respectively. + + Error details: + ${error.message || 'Unknown exception in the render tree.'}`; + + const handleCopy = async () => { + try { + await navigator.clipboard.writeText(terminalContent); + toast.success('Terminal output copied!'); + } catch { + toast.error('Failed to copy terminal output'); + } + }; + + return ( +
+
+ ); +} diff --git a/app/global-error.tsx b/app/global-error.tsx new file mode 100644 index 000000000..f8d4c1a8d --- /dev/null +++ b/app/global-error.tsx @@ -0,0 +1,34 @@ +'use client'; +import Link from 'next/link'; + +export default function GlobalError({ + error, + reset, +}: { + error: Error & { digest?: string }; + reset: () => void; +}) { + return ( + + +
+
+

500

+

A critical error occurred at the root level.

+
+ + {error.message || 'Unknown global error'} + +
+ +
+
+ + + ); +}