Error Handling

Error Handling

Route errors, boundaries, and status codes.

Updated: 2026-07-26

Error entities

pages/error.tsx handles route errors globally and renders with a 500 status. pages/404.tsx handles not-found and renders with 404. Both are marked noindex automatically.

A page module can also export errorBoundary for a route-level boundary that takes precedence over the global one.

src/pages/error.tsx
import type { SiteErrorContext } from '@rigbyhost/karui/ssr';

export default function ErrorPage(ctx: SiteErrorContext) {
  const message = ctx.error instanceof Error ? ctx.error.message : String(ctx.error);
  return <pre>{message}</pre>;
}

Errors versus control flow

notFound() and redirect() throw, but they are control flow rather than failures. An error boundary never catches them: notFound() routes into your 404 entity, and redirect() reaches the transport as a Location header.