---
title: "Contain each crash to its panel · Agent Wranglers"
url: https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures/error-boundaries
updated: 2026-10-20
licence: "All rights reserved"
---

# Contain each crash to its panel

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Permissions, flags and failures](https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures)
- Rule: Wrap each route and each independent panel in an error boundary. One broken part then shows a fallback, and the rest keeps working. Report every caught error.
- How: Use the framework's boundary, such as `ErrorBoundary` in React, `onErrorCaptured` in Vue, or `<svelte:boundary>` in Svelte. Angular has no boundary per component, so catch errors in each panel's data stream and keep a global `ErrorHandler` for the rest. The fallback names the part that failed, offers a retry and shows a reference. Send the error to your collector, as [browser error reports](https://agentwranglers.se/playbook/website/when-things-break/browser-error-reports) describes. In a server-rendered app, render each panel in its own `try` block, so one failure returns a fallback partial.
- Check: A test makes one panel throw during render. The other panels and the navigation still render, the fallback shows a retry button, and one error report is sent.

Example:

```tsx
export class PanelBoundary extends React.Component<{ name: string; children: React.ReactNode }, { reference?: string }> {
  state: { reference?: string } = {};
  static getDerivedStateFromError() { return { reference: crypto.randomUUID().slice(0, 8) }; }
  componentDidCatch(error: Error) { reportError({ error, panel: this.props.name, reference: this.state.reference }); }
  render() {
    if (!this.state.reference) return this.props.children;
    return <PanelFallback name={this.props.name} reference={this.state.reference} onRetry={() => this.setState({ reference: undefined })} />;
  }
}
```

```python
def render_panel(name: str, render) -> str:
    try:
        return render()
    except Exception:
        reference = uuid.uuid4().hex[:8]
        log.exception("panel.render_failed", panel=name, reference=reference)
        return render_template("panels/_fallback.html", name=name, reference=reference)
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers app interface playbook: https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures/error-boundaries`.

- Previous: [Read feature flags before the first paint](https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures/feature-flags-in-ui)
- Next: [Give every request a time limit](https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures/request-timeouts)
- [Permissions, flags and failures](https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures)
