import { AlertTriangle, RefreshCw } from "lucide-react"; import { Component, type ErrorInfo, type ReactNode } from "react"; import { Button } from "@/client/components/ui/button"; interface Props { children: ReactNode; // Used by route-level boundaries to reset on navigation. When the key // changes, the boundary remounts and clears its captured error. resetKey?: string; } interface State { error: Error | null; } // Class component because React's error-boundary contract still lives on // componentDidCatch / getDerivedStateFromError. Wraps the route Outlet // in app-shell so a runtime exception in any page renders a recoverable // surface instead of blanking the whole app. export class ErrorBoundary extends Component { state: State = { error: null }; static getDerivedStateFromError(error: Error): State { return { error }; } componentDidCatch(error: Error, info: ErrorInfo): void { // Surface in the dev console so the stack is reachable; production // observability can hook here if/when we add a reporter. console.error("[error-boundary]", error, info.componentStack); } componentDidUpdate(prev: Props): void { if (prev.resetKey !== this.props.resetKey && this.state.error) { this.setState({ error: null }); } } render(): ReactNode { if (!this.state.error) return this.props.children; return (

This page hit an unexpected error. The details below are useful when reporting the issue.

            {this.state.error.message}
          
); } }