import { Component, ReactNode, ErrorInfo } from 'react'; import { Center, Stack, Text, Button, Alert, rem } from '@mantine/core'; import { AlertTriangle, FolderOpen } from 'lucide-react'; import { safeExecute } from '@/utils/logger'; interface Props { children: ReactNode; } interface State { hasError: boolean; error?: Error; } export class ErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } componentDidCatch(error: Error, _errorInfo: ErrorInfo) { window.electronAPI?.logs?.logError( 'App crashed with unhandled error:', error ); } render() { if (this.state.hasError) { return (
Application Error The application encountered an unexpected error and crashed. You can view the error details in the logs folder. {this.state.error && ( {this.state.error.message} )}
); } return this.props.children; } }