import { Component, type ErrorInfo, type ReactNode } from 'react'; import { AlertTriangle, RefreshCcw } from 'lucide-react'; import { Button } from './Button'; interface Props { children?: ReactNode; fallback?: ReactNode; appName?: string; } interface State { hasError: boolean; error: Error | null; } export class ErrorBoundary extends Component { public state: State = { hasError: false, error: null }; public static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } public componentDidCatch(error: Error, errorInfo: ErrorInfo) { console.error(`[ErrorBoundary] Caught error in ${this.props.appName || 'component'}:`, error, errorInfo); } private handleReset = () => { this.setState({ hasError: false, error: null }); }; public render() { if (this.state.hasError) { if (this.props.fallback) { return this.props.fallback; } return (

Error en el módulo {this.props.appName && `"${this.props.appName}"`}

{this.state.error?.message || "Ha ocurrido un error inesperado al renderizar este micro-frontend."}

); } return this.props.children; } }