import { Component, type ErrorInfo, type ReactNode } from "react"; import { t } from "../i18n"; interface Props { children: ReactNode; } interface State { error: Error | null; } /** Sicherheitsnetz: fängt Render-Fehler ab, statt die Seite weiß zu lassen. */ export class ErrorBoundary extends Component { state: State = { error: null }; static getDerivedStateFromError(error: Error): State { return { error }; } componentDidCatch(error: Error, info: ErrorInfo): void { console.error(t("error.console"), error, info); } render(): ReactNode { if (this.state.error) { return (

{t("error.title")}

{t("error.body")}

{this.state.error.message}
); } return this.props.children; } }