DEV Community

Sherotree
Sherotree

Posted on

Give the agent the existing error-boundary map, don’t invent a new one per page

The agent adds a new settings page and wraps the whole file in a brand-new <ErrorBoundary fallback={<p>Something went wrong</p>}>. The app already has a route-level boundary, a feature-level one around the editor, and a shared fallback that reports to the logger. The new wrapper swallows the error, skips the report, and looks different from every other failure screen.

I’ve started treating a one-off error boundary in an agent PR as a smell. If the repo already has a map — which routes own a boundary, which widgets are isolated, what the fallback is — the model should use that map. It should not invent a fourth kind of “something went wrong.”

Why a new boundary is usually wrong

The model has seen a million examples that start with “wrap it in an error boundary.” That advice is correct at the architecture level and wrong at the leaf. Two boundaries in a row, with different fallbacks, make recovery harder to reason about. A boundary that does not call the existing logError helper makes the page look fine in the UI and silent in the dashboard.

There are real reasons to add a boundary: a third-party widget, an isolated editor, a route the team has not wrapped yet. Those reasons should be in the PR, and the fallback should be the shared one unless you are designing a new tier.

A simple boundary policy

  • Read the existing map first — app/error.tsx, src/lib/boundaries.md, the router wrappers
  • Reuse the shared fallback and logger
  • Add a new boundary only for a new isolation tier, named and documented on the map
  • No inline fallback={<div>Error</div>} in a random page

If the framework already provides route error elements (Next.js error.tsx, Remix ErrorBoundary), prefer those over a custom wrapper in the page module.

What to put in the prompt

Here is how errors are isolated in this app (see src/lib/error-boundaries.md or the root ErrorBoundary).
Do not add a new ErrorBoundary around a page that is already covered.
If this feature needs isolation, use the shared fallback and logger, and update the map.
Do not invent a one-off “Something went wrong” message.
Enter fullscreen mode Exit fullscreen mode

Paste the map or the existing boundary component. In review, search the diff for ErrorBoundary and componentDidCatch. New hits need a reason.

Async errors are a special case. A render boundary will not catch a failed fetch unless you map that failure into state or a router error. If the agent added a boundary “to handle the API error,” it probably did not. Point it at the existing query-library error UI or the route’s error.tsx, and keep the boundary for render-time failures.

If the new page is a modal or a drawer, isolating it can be right — a crash in a dialog should not blank the whole settings route. Use the shared fallback, still, and say on the map that the dialog is an isolation tier.

Reject / send back

Reject

  • A page-level wrapper that duplicates the route boundary
  • A fallback that does not report to the existing logger
  • A unique error illustration for one page, unless that is an explicit request
  • Swallowing the error and rendering an empty state

Accept

  • A feature that relies on the existing route or app boundary
  • A new, documented isolation tier with the shared fallback
  • A framework error.tsx that matches the rest of the app

Top comments (0)