import { Component, type ErrorInfo, type ReactNode } from 'react' interface Props { children: ReactNode } interface State { error: Error | undefined } /** * Top-level render guard. Without this, any throw during render white-screens the * whole console (the whole point of finding #1). We catch it, log it for the * console, and show a friendly recover-with-reload fallback instead of a blank page. * * Deliberately self-contained (no @sims/ui import): the boundary must keep working * even when the failure is in a shared component it would otherwise render. */ export class ErrorBoundary extends Component { state: State = { error: undefined } static getDerivedStateFromError(error: Error): State { return { error } } componentDidCatch(error: Error, info: ErrorInfo): void { // Surface it in the browser console for whoever's debugging; no telemetry sink yet. console.error('Console crashed while rendering:', error, info.componentStack) } private readonly reset = (): void => this.setState({ error: undefined }) render(): ReactNode { const { error } = this.state if (error === undefined) return this.props.children return (
⚠️

Something went wrong

The console hit an unexpected error and couldn’t finish rendering this screen. Your data is safe on the server — reloading usually clears it.

{error.message}
) } }