1+ import Bugsnag from "@bugsnag/js" ;
12import { type ErrorComponentProps , useRouter } from "@tanstack/react-router" ;
3+ import { useEffect } from "react" ;
24
35import { InfoBox } from "@/components/shared/InfoBox" ;
46import { Button } from "@/components/ui/button" ;
57import { BlockStack } from "@/components/ui/layout" ;
68import { Paragraph , Text } from "@/components/ui/typography" ;
9+ import { getBugsnagConfig } from "@/services/errorManagement/bugsnag" ;
710
8- export default function ErrorPage ( { error } : ErrorComponentProps ) {
11+ export const ErrorPage = ( { error, reset } : ErrorComponentProps ) => {
912 const router = useRouter ( ) ;
1013
14+ useEffect ( ( ) => {
15+ const config = getBugsnagConfig ( ) ;
16+
17+ if ( config . enabled && error instanceof Error ) {
18+ Bugsnag . notify ( error , ( event ) => {
19+ event . addMetadata ( "error_handler" , {
20+ pathname : window . location . pathname ,
21+ } ) ;
22+ } ) ;
23+ }
24+ } , [ error ] ) ;
25+
1126 const handleRefresh = ( ) => {
27+ // Reset error boundary if available (some callers provide this function)
28+ reset ?.( ) ;
1229 window . location . reload ( ) ;
1330 } ;
1431
1532 const handleGoHome = ( ) => {
33+ // Reset error boundary if available (some callers provide this function)
34+ reset ?.( ) ;
1635 router . navigate ( { to : "/" } ) ;
1736 } ;
1837
38+ const errorMessage =
39+ error instanceof Error ? error . message : "An unexpected error occurred" ;
40+
1941 return (
2042 < div className = "min-h-screen flex items-center justify-center bg-background p-4" >
2143 < div className = "max-w-xs w-full" >
@@ -31,7 +53,7 @@ export default function ErrorPage({ error }: ErrorComponentProps) {
3153
3254 < InfoBox title = "Error Details" variant = "error" >
3355 < Paragraph font = "mono" size = "xs" >
34- { error ?. message || "An unexpected error occurred" }
56+ { errorMessage }
3557 </ Paragraph >
3658 </ InfoBox >
3759
@@ -52,4 +74,4 @@ export default function ErrorPage({ error }: ErrorComponentProps) {
5274 </ div >
5375 </ div >
5476 ) ;
55- }
77+ } ;
0 commit comments