tsx import React, { Component, ErrorInfo, ReactNode } from 'react' import { AlertTriangle, RefreshCw } from 'lucide-react' /** * Props for the ErrorBoundary component */ interface ErrorBoundaryProps { children: ReactNode } /** * State for the ErrorBoundary component */ interface ErrorBoundaryState { hasError: boolean error: Error | null errorInfo: ErrorInfo | null } /** * Error Boundary component to catch and handle React errors gracefully * Provides user-friendly error messages and recovery options */ export class ErrorBoundary extends Component { constructor(props: ErrorBoundaryProps) { super(props) this.state = { hasError: false, error: null, errorInfo: null } } /** * Static method to catch errors and update state */ static getDerivedStateFromError(error: Error): Partial { return { hasError: true, error } } /** * ComponentDidCatch to log error details */ componentDidCatch(error: Error, errorInfo: ErrorInfo) { console.error('ErrorBoundary caught an error:', error, errorInfo) this.setState({ error, errorInfo }) // In a real app, you might want to send this to an error reporting service // reportError(error, errorInfo) } /** * Handle retry after error */ handleRetry = () => { this.setState({ hasError: false, error: null, errorInfo: null }) } /** * Handle refresh page */ handleRefresh = () => { window.location.reload() } render() { if (this.state.hasError) { return (

Etwas ist schiefgelaufen

Es ist ein unerwarteter Fehler aufgetreten. Bitte versuche es erneut oder lade die Seite neu.

{process.env.NODE_ENV === 'development' && this.state.error && (
Technische Details (Entwicklungsmodus)
                  {this.state.error.toString()}
                  {this.state.errorInfo?.componentStack}
                
)}

Falls das Problem besteht, kontaktiere bitte den Support.

) } return this.props.children } }