IT lexicon › Programming › Error boundary

Error boundary

Programming På svenska → Updated: 2026-05-27

React pattern: a class component that catches JavaScript errors in its subtree and shows fallback UI instead of crashing the whole app. componentDidCatch + getDerivedStateFromError lifecycle methods.

Limitation: catches only errors during render, lifecycle, or constructor. Async errors (Promises, event handlers, setTimeout) must be caught with try/catch or window.onerror. Functional-component version: react-error-boundary library (TanStack-style). Vue equivalent: errorCaptured. Angular: ErrorHandler service. Modern monitoring (Sentry, DataDog RUM) is typically installed as an error boundary at root level for automatic reporting. Anti-pattern: an error boundary that swallows errors without logging → silent failures, debug nightmare.

← Back to the lexicon