Error handling with error.js boundaries
Answer: Errors can be divided into expected errors and uncaught exceptions. An error file shows fallback UI for unexpected runtime errors in a segment.
Expected vs uncaught
Expected errors should be modeled as return values. Uncaught exceptions are unexpected errors that indicate bugs.
error.js
An error file lets you handle unexpected runtime errors and display fallback UI. Next.js uses error boundaries to handle uncaught exceptions.
See also
Claims
- id: C1 claim: Errors split into expected and uncaught. source: S1 evidence: "Errors can be divided into two categories: expected errors and uncaught exceptions."
- id: C2 claim: Model expected errors as return values. source: S1 evidence: "Instead, model expected errors as return values."
- id: C3 claim: error files show fallback UI. source: S2 evidence: "An error file allows you to handle unexpected runtime errors and display fallback UI."
- id: C4 claim: Next.js uses error boundaries for uncaught exceptions. source: S1 evidence: "Next.js uses error boundaries to handle uncaught exceptions."
Sources
- [S1] Error handling. Next.js docs. https://nextjs.org/docs/app/getting-started/error-handling . License: MIT (vercel/next.js). Accessed 2026-11-09.
- [S2] error.js. Next.js docs. https://nextjs.org/docs/app/api-reference/file-conventions/error . License: MIT (vercel/next.js). Accessed 2026-11-09.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Copyright (c) 2025 Vercel, Inc. Sources: Next.js docs (vercel/next.js on GitHub / nextjs.org), MIT (https://raw.githubusercontent.com/vercel/next.js/canary/license.md). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Next.js docs, Error handling, MIT (vercel/next.js); Next.js docs, error.js, MIT (vercel/next.js). Copyright (c) 2025 Vercel, Inc. MIT (https://raw.githubusercontent.com/vercel/next.js/canary/license.md).
Cite this
iinventedlight. 2026. "Error handling with error.js boundaries." iinventedlight Library, iil:note:kedkyfs6, version of 2026-11-09. https://iinventedlight.com/library/notes/nextjs-error-handling/. License: CC-BY-4.0.
@misc{iil_note_kedkyfs6,
author = {{iinventedlight}},
title = {{Error handling with error.js boundaries}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-09},
url = {https://iinventedlight.com/library/notes/nextjs-error-handling/},
note = {Permanent ID iil:note:kedkyfs6. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/nextjs-error-handling.md.