import { Component, type ErrorInfo, type ReactNode } from "react"; interface Props { children: ReactNode; } interface State { error: Error | null; } /** * Catches render/runtime errors in a page so a single failing visualisation * (e.g. a lost WebGL context) never blanks the whole dashboard. */ export class ErrorBoundary extends Component { state: State = { error: null }; static getDerivedStateFromError(error: Error): State { return { error }; } componentDidCatch(error: Error, info: ErrorInfo): void { console.error("[dashboard] page crashed", error, info.componentStack); } render(): ReactNode { if (this.state.error) { return (

This view failed to render.

{this.state.error.message}. Try reloading the page or switching views.

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