import React from 'react'; import { AlertTriangle, RefreshCw, Home } from 'lucide-react'; import { Button } from '@/components/ui/button'; interface ErrorBoundaryState { hasError: boolean; error: Error | null; } interface ErrorBoundaryProps { children: React.ReactNode; fallback?: React.ReactNode; onReset?: () => void; } export class ErrorBoundary extends React.Component { constructor(props: ErrorBoundaryProps) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error: Error): ErrorBoundaryState { return { hasError: true, error }; } handleReset = () => { this.setState({ hasError: false, error: null }); this.props.onReset?.(); }; override render() { if (this.state.hasError) { if (this.props.fallback) return this.props.fallback; return (
{/* Animated icon */}

Something went wrong

An unexpected error occurred. This has been logged and we'll look into it.

{/* Error details (collapsible) */} {this.state.error && (
Technical details
                {this.state.error.message}
              
)} {/* Actions */}
); } return this.props.children; } }