1. ErrorBoundary
The basic boundary, for a small unit such as a component preview.
2. SectionErrorBoundary
The workhorse. Every page section in the five-layer
architecture gets one. It shows the section name, offers a retry, and
logs through the observability library without any wiring on your part.
Props
The
section string is doing two jobs: it names the thing the reader lost, and it is the
handle you grep for when the log shows up. Make it the name a person would use.
3. Route and global boundaries
Next.js provides both. The route boundary (app/error.tsx) catches errors within a route
segment and offers a retry. The global boundary (app/global-error.tsx) is the last resort —
it wraps the whole document, and it uses hardcoded colours because CSS custom properties may
not have loaded by the time it renders.
That hardcoded-colour exception is the one place the “no raw hex outside N1” rule is
deliberately broken, and the reason is the same reason the boundary exists: it has to render
when the rest of the system has not.
Install
section-error-boundary is an N5 resilience component; it lives at
components/registry/n5-resilience/ in the registry repository.