/ src / app / global-error.tsx
global-error.tsx
 1  'use client'
 2  
 3  import { useEffect } from 'react'
 4  
 5  import './globals.css'
 6  
 7  import { ErrorFallback } from '@/components/layout/error-fallback'
 8  import { reportClientError } from '@/lib/app/report-client-error'
 9  
10  export default function GlobalError({
11    error,
12  }: {
13    error: Error & { digest?: string }
14  }) {
15    useEffect(() => {
16      reportClientError({
17        source: 'global-error',
18        error,
19        digest: error.digest,
20      })
21    }, [error])
22  
23    return (
24      <html lang="en" className="dark">
25        <body className="antialiased">
26          <ErrorFallback
27            message="A fatal application error occurred before the normal shell could recover. Reload the app to continue."
28            onPrimaryAction={() => window.location.reload()}
29          />
30        </body>
31      </html>
32    )
33  }