import { Component } from 'react'; import type { ReactNode, ErrorInfo } from 'react'; import { Center, Paper, Title, Text, Button } from '@mantine/core'; import { withTranslation } from 'react-i18next'; import type { WithTranslation } from 'react-i18next'; interface Props extends WithTranslation { children: ReactNode; } interface State { hasError: boolean; error: Error | null; } class ErrorBoundaryBase extends Component { state: State = { hasError: false, error: null }; static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } componentDidCatch(error: Error, info: ErrorInfo) { console.error('ErrorBoundary caught:', error, info); } render() { if (this.state.hasError) { const { t } = this.props; return (
{t('errorBoundary.title')} {this.state.error?.message || t('errorBoundary.message')}
); } return this.props.children; } } export const ErrorBoundary = withTranslation()(ErrorBoundaryBase);