diff --git a/web/client/src/components/ErrorBoundary.jsx b/web/client/src/components/ErrorBoundary.jsx new file mode 100644 index 0000000..bad453f --- /dev/null +++ b/web/client/src/components/ErrorBoundary.jsx @@ -0,0 +1,34 @@ +import { Component } from "react"; + +export default class ErrorBoundary extends Component { + constructor(props) { + super(props); + this.state = { hasError: false, message: "" }; + } + + static getDerivedStateFromError(err) { + return { hasError: true, message: err?.message || "Unknown error" }; + } + + componentDidCatch(err, info) { + console.error("[ErrorBoundary]", err, info); + } + + render() { + if (this.state.hasError) { + return ( +
{this.state.message}
+ +