File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change
1
+ // app/error.tsx
2
+
1
3
'use client' // Error boundaries must be Client Components
2
4
3
5
import { useEffect } from 'react'
6
+ import { reportError } from '@/lib/errorReportingService' // 1. Import the service
4
7
5
8
export default function Error ( {
6
9
error,
@@ -10,18 +13,24 @@ export default function Error({
10
13
reset : ( ) => void
11
14
} ) {
12
15
useEffect ( ( ) => {
13
- // Log the error to an error reporting service
14
- console . error ( error )
16
+ // 2. Log the error to your reporting service instead of just the console
17
+ reportError ( error )
15
18
} , [ error ] )
16
19
17
20
return (
18
- < div >
21
+ < div style = { { padding : '2rem' , textAlign : 'center' } } >
19
22
< h2 > Something went wrong!</ h2 >
23
+ < p > An error occurred while loading this page.</ p >
20
24
< button
21
25
onClick = {
22
26
// Attempt to recover by trying to re-render the segment
23
27
( ) => reset ( )
24
28
}
29
+ style = { {
30
+ marginTop : '1rem' ,
31
+ padding : '0.5rem 1rem' ,
32
+ cursor : 'pointer' ,
33
+ } }
25
34
>
26
35
Try again
27
36
</ button >
You can’t perform that action at this time.
0 commit comments