import React from 'react'; import { motion } from 'framer-motion'; import { AlertTriangle, RefreshCw, Home } from 'lucide-react'; import Button from '../design-system/components/Button'; import Card from '../design-system/components/Card'; class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false, error: null, errorInfo: null, retryCount: 0 }; } static getDerivedStateFromError(error) { return { hasError: true }; } componentDidCatch(error, errorInfo) { this.setState({ error, errorInfo, }); // Log error to monitoring service in production if (process.env.NODE_ENV === 'production') { console.error('Error caught by boundary:', error, errorInfo); // Here you would typically send to error monitoring service // e.g., Sentry.captureException(error, { extra: errorInfo }); } } handleRetry = () => { this.setState(prevState => ({ hasError: false, error: null, errorInfo: null, retryCount: prevState.retryCount + 1 })); }; handleGoHome = () => { window.location.href = '/'; }; render() { if (this.state.hasError) { return (
{this.state.error.toString()}
{this.state.errorInfo.componentStack}