import { Component, type ErrorInfo, type ReactNode } from 'react' import { AlertTriangle, RefreshCw } from 'lucide-react' import { Button } from '@/components/ui/button' interface Props { children: ReactNode fallback?: ReactNode } interface State { error: Error | null } export class ErrorBoundary extends Component { state: State = { error: null } static getDerivedStateFromError(error: Error): State { return { error } } componentDidCatch(error: Error, info: ErrorInfo) { console.error('[ErrorBoundary]', error, info.componentStack) } reset = () => this.setState({ error: null }) render() { if (this.state.error) { if (this.props.fallback) return this.props.fallback return (

Something went wrong

{this.state.error.message}

) } return this.props.children } }