From 7394ce8754227f7f448729e665e4bfb521199a34 Mon Sep 17 00:00:00 2001 From: basantnema31 Date: Sun, 7 Jun 2026 22:51:08 +0530 Subject: [PATCH 1/2] feat: implement global error boundary and exception handling mechanism --- app/error.tsx | 125 +++++++++++++++++++++++++++++++++++++++++++ app/global-error.tsx | 34 ++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 app/error.tsx create mode 100644 app/global-error.tsx diff --git a/app/error.tsx b/app/error.tsx new file mode 100644 index 000000000..b14700921 --- /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..65747d03f --- /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'} + +
+ +
+
+ + + ); +} From deb7d0a5d104fad0be6951c4f2c62606b0052940 Mon Sep 17 00:00:00 2001 From: basantnema31 Date: Sun, 7 Jun 2026 22:58:06 +0530 Subject: [PATCH 2/2] style: run prettier formatting to fix CI pipeline --- app/error.tsx | 8 ++++---- app/global-error.tsx | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/error.tsx b/app/error.tsx index b14700921..4667ff618 100644 --- a/app/error.tsx +++ b/app/error.tsx @@ -81,15 +81,15 @@ export default function ErrorBoundary({

~ $ - - git status - + git status

fatal: Your branch and 'origin/main' have diverged.
- {error.message || 'Unknown runtime error occurred.'} + + {error.message || 'Unknown runtime error occurred.'} +

diff --git a/app/global-error.tsx b/app/global-error.tsx index 65747d03f..f8d4c1a8d 100644 --- a/app/global-error.tsx +++ b/app/global-error.tsx @@ -16,9 +16,9 @@ export default function GlobalError({

500

A critical error occurred at the root level.

- - {error.message || 'Unknown global error'} - + + {error.message || 'Unknown global error'} +