// Top-level error boundary. React eats thrown errors silently by default, // which in an Electron app with no URL bar means "blank window, nothing // to click" from the user's perspective. This component at least shows // the error text + stack so we can copy-paste it into a bug report. import React from 'react'; interface State { error: Error | null; } export class ErrorBoundary extends React.Component< { children: React.ReactNode }, State > { state: State = { error: null }; static getDerivedStateFromError(error: Error): State { return { error }; } componentDidCatch(error: Error, info: React.ErrorInfo): void { // Surface the exception in the devtools console too, for quick // copy-paste when the boundary is blocking the UI. console.error('[ErrorBoundary]', error, info); } render(): React.ReactNode { if (!this.state.error) return this.props.children; return (

Something broke.

{this.state.error.message}

          {this.state.error.stack}
        
); } }