import React, { Component, ErrorInfo, ReactNode } from 'react'; import { ThemeService } from '../services/themeService'; interface Props { children?: ReactNode; } interface State { hasError: boolean; error?: Error; } export default class ErrorBoundary extends Component { public state: State = { hasError: false }; public static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } public componentDidCatch(error: Error, errorInfo: ErrorInfo) { console.error('Uncaught error:', error, errorInfo); } public render() { if (this.state.hasError) { const themeService = ThemeService.getInstance(); try { const errorTemplate = themeService.getTemplate('error'); return
; } catch (e) { return (

Something went wrong

{this.state.error?.message}

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