11import { Button , Card , Flex , Text } from "@radix-ui/themes" ;
22import { logger } from "@renderer/lib/logger" ;
3- import { toast } from "@utils/toast" ;
43import type { ReactNode } from "react" ;
54import { ErrorBoundary as ReactErrorBoundary } from "react-error-boundary" ;
65
@@ -9,7 +8,13 @@ interface Props {
98 fallback ?: ReactNode ;
109}
1110
12- function DefaultFallback ( { onReset } : { onReset : ( ) => void } ) {
11+ function DefaultFallback ( {
12+ error,
13+ onReset,
14+ } : {
15+ error : Error ;
16+ onReset : ( ) => void ;
17+ } ) {
1318 return (
1419 < Flex align = "center" justify = "center" minHeight = "100vh" p = "4" >
1520 < Card size = "3" style = { { maxWidth : 400 } } >
@@ -18,7 +23,7 @@ function DefaultFallback({ onReset }: { onReset: () => void }) {
1823 Something went wrong
1924 </ Text >
2025 < Text size = "2" color = "gray" align = "center" >
21- An unexpected error occurred. Please try again.
26+ { error . message }
2227 </ Text >
2328 < Button onClick = { onReset } variant = "soft" >
2429 Try again
@@ -32,16 +37,17 @@ function DefaultFallback({ onReset }: { onReset: () => void }) {
3237export function ErrorBoundary ( { children, fallback } : Props ) {
3338 return (
3439 < ReactErrorBoundary
35- fallbackRender = { ( { resetErrorBoundary } ) =>
36- fallback ?? < DefaultFallback onReset = { resetErrorBoundary } />
40+ fallbackRender = { ( { error, resetErrorBoundary } ) =>
41+ fallback ?? (
42+ < DefaultFallback error = { error } onReset = { resetErrorBoundary } />
43+ )
3744 }
3845 onError = { ( error , info ) => {
3946 logger . error ( "React error boundary caught error" , {
4047 error : error . message ,
4148 stack : error . stack ,
4249 componentStack : info . componentStack ,
4350 } ) ;
44- toast . error ( "Something went wrong" , { description : error . message } ) ;
4551 } }
4652 >
4753 { children }
0 commit comments