diff options
| author | Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> | 2025-03-04 12:15:10 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> | 2025-03-04 12:15:10 +0100 |
| commit | 0c0983428b387a587dc71baed30d7a16178b3ef2 (patch) | |
| tree | 6b23a56cd341fa4941681ba1efea07bed10c184e /src/ErrorBoundary.tsx | |
| parent | 6677ce3906670afd2a2d13e91f37ccadebca12a7 (diff) | |
Fix build process
Diffstat (limited to 'src/ErrorBoundary.tsx')
| -rw-r--r-- | src/ErrorBoundary.tsx | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/ErrorBoundary.tsx b/src/ErrorBoundary.tsx index d3f5a60..2372f9b 100644 --- a/src/ErrorBoundary.tsx +++ b/src/ErrorBoundary.tsx @@ -6,16 +6,23 @@ interface ErrorBoundaryProps { interface ErrorBoundaryState { hasError: boolean; + error: Error | null; } class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> { constructor(props: ErrorBoundaryProps) { super(props); - this.state = { hasError: false }; + this.state = { + hasError: false, + error: null + }; } - static getDerivedStateFromError(_: Error): ErrorBoundaryState { - return { hasError: true }; + static getDerivedStateFromError(error: Error): ErrorBoundaryState { + return { + hasError: true, + error + }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { @@ -24,7 +31,12 @@ class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> { render() { if (this.state.hasError) { - return <h1>Something went wrong.</h1>; + return <> + <h1>Something went wrong.</h1> + <pre> + {this.state.error?.stack} + </pre> + </>; } return this.props.children; |
