From 036117047f32e5bf7244dadf9dd73ec03e6f1ecd Mon Sep 17 00:00:00 2001 From: wheattoast11 Date: Sat, 30 Nov 2024 14:11:20 -0600 Subject: [PATCH] update error boundary --- src/components/ErrorBoundary.jsx | 44 ++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/src/components/ErrorBoundary.jsx b/src/components/ErrorBoundary.jsx index b74b6e5..7842981 100644 --- a/src/components/ErrorBoundary.jsx +++ b/src/components/ErrorBoundary.jsx @@ -8,12 +8,16 @@ class ErrorBoundary extends React.Component { error: null, errorInfo: null }; + console.log('ErrorBoundary constructed'); } static getDerivedStateFromError(error) { - console.log('ErrorBoundary getDerivedStateFromError:', error); - console.log('Error type:', error?.constructor?.name); - console.log('Error message:', error?.message); + console.log('ErrorBoundary getDerivedStateFromError:', { + error, + type: error?.constructor?.name, + message: error?.message, + stack: error?.stack + }); if (error && !error.message?.includes('Failed to load resource') && @@ -25,8 +29,13 @@ class ErrorBoundary extends React.Component { } componentDidCatch(error, errorInfo) { - console.log('ErrorBoundary componentDidCatch:', error); - console.log('Component stack:', errorInfo?.componentStack); + console.log('ErrorBoundary componentDidCatch:', { + error, + type: error?.constructor?.name, + message: error?.message, + stack: error?.stack, + componentStack: errorInfo?.componentStack + }); if (error && !error.message?.includes('Failed to load resource') && @@ -39,7 +48,22 @@ class ErrorBoundary extends React.Component { } } + componentDidMount() { + console.log('ErrorBoundary mounted'); + } + + componentDidUpdate() { + console.log('ErrorBoundary updated', { + hasError: this.state.hasError, + error: this.state.error + }); + } + render() { + console.log('ErrorBoundary rendering', { + hasError: this.state.hasError + }); + if (this.state.hasError) { return (

Something went wrong

Please refresh the page or try again later.

+ {process.env.NODE_ENV === 'development' && ( +
+                {this.state.error && this.state.error.toString()}
+              
+ )}
);