import React from 'react'; import { AlertCircle, BookOpen, RefreshCw } from 'lucide-react'; import { classifyError, openDocsFor } from '../utils/errorDocsMap'; import './WaveformErrorBoundary.css'; export default class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { error: null }; } static getDerivedStateFromError(error) { return { error }; } componentDidCatch(error, info) { // Surface via console.error so it reaches our ring buffer (Settings > Logs > Frontend). // eslint-disable-next-line no-console console.error(`[ErrorBoundary:${this.props.name || 'anon'}]`, error, info?.componentStack); } reset = () => this.setState({ error: null }); openDocs = async () => { const cls = this.state.error?.errorClass /* explicit hint from the thrower */ || classifyError(this.state.error); try { await openDocsFor(cls); } catch (err) { // openExternal already falls back to window.open; swallow any // remaining failure so the error boundary itself never throws. // eslint-disable-next-line no-console console.warn('[ErrorBoundary] openDocsFor failed', err); } }; render() { if (!this.state.error) return this.props.children; const msg = this.state.error?.message || String(this.state.error); return (

This tab hit a snag.

Don't worry — the rest of the app still works. You can switch tabs, or try again below.

{msg}
); } }