diff --git a/packages/bruno-app/src/pages/ErrorBoundary/index.js b/packages/bruno-app/src/pages/ErrorBoundary/index.js new file mode 100644 index 000000000..3b45122ab --- /dev/null +++ b/packages/bruno-app/src/pages/ErrorBoundary/index.js @@ -0,0 +1,44 @@ +import React from 'react'; + +class ErrorBoundary extends React.Component { + constructor(props) { + super(props); + + this.state = { hasError: false }; + } + componentDidMount() { + // Add a global error event listener to capture client-side errors + window.onerror = (message, source, lineno, colno, error) => { + this.setState({ hasError: true, error }); + }; + } + componentDidCatch(error, errorInfo) { + console.log({ error, errorInfo }); + } + render() { + if (this.state.hasError) { + return ( +
{this.state.error && this.state.error.toString()}
+ {this.state.error && this.state.error.stack && ( +{this.state.error.stack}
+ )}
+
+