import { AlertTriangle, RotateCcw } from 'lucide-react' import { Component, type ErrorInfo, type ReactNode } from 'react' import { Button } from '@/components/ui/button' interface Props { children: ReactNode } interface State { hasError: boolean error: Error | null } export class ErrorBoundary extends Component { state: State = { hasError: false, error: null } static getDerivedStateFromError(error: Error): State { return { hasError: true, error } } componentDidCatch(error: Error, errorInfo: ErrorInfo) { console.error('[ErrorBoundary]', error, errorInfo.componentStack) } handleReload = () => { window.location.reload() } render() { if (!this.state.hasError) { return this.props.children } return (

Something went wrong

{this.state.error?.message || 'An unexpected error occurred'}

) } }