import { Clipboard, RefreshCw, ServerCrash } from 'lucide-react'; import { Component, type ErrorInfo, type ReactNode } from 'react'; import log from 'electron-log/renderer'; import { useT } from '~renderer/i18n'; import PageBackground from './assets/background.png'; import TextButton from './components/styled/TextButton'; type State = { didCatch?: boolean; error?: Error; errorInfo?: ErrorInfo; }; type Props = { children: ReactNode; }; const ErrorFallback = ({ error, errorInfo }: { error?: Error; errorInfo?: ErrorInfo; }) => { const t = useT(); const title = t('misc.uncaughtError', { name: error?.name ?? '', message: error?.message ?? t('misc.unknownError') }); const detail = errorInfo?.componentStack?.slice(1); return (

{t('misc.somethingWentWrong')}


{title}
					{detail}
				

navigator.clipboard.writeText( `\`\`\`\n${title}\n${detail}\n\`\`\`` ) } > {t('misc.copyError')} window.location.reload()} className="text-warmGreen" > {t('misc.reload')}
); }; class ErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = {}; } componentDidCatch(error: Error, errorInfo: ErrorInfo) { log.error('Client crash:', error, errorInfo); this.setState({ didCatch: true, error, errorInfo }); } render() { if (!this.state.didCatch) return this.props.children; const { error, errorInfo } = this.state; return ; } } export default ErrorBoundary;