Throw a control-flow function from a page (or a page
action) to short-circuit the render. The
framework catches it and renders the nearest matching boundary file in the
route's chain, innermost wins.
forbidden(), caught by
gated/forbidden.ts (403).
unauthorized(), caught by
private/unauthorized.ts (401).
error.ts (500).
not-found.ts (404).
forbidden() is for an authenticated user who
lacks permission (403); unauthorized() is for
a request that is not authenticated at all (401). Both import from
@webjsdev/core and are thrown, never returned.
Same throw model as notFound() (renders the
nearest not-found.ts) and
redirect(url) (sends an HTTP 3xx). Inside a
'use server' RPC action, return an
ActionResult for an auth failure instead of
throwing, since a raw throw there is a generic 500.
Two boundaries are root-only and live at the app root:
app/global-error.ts (the app-wide catch-all,
which renders its own <html> document)
and app/global-not-found.ts (a 404 for a URL
that matches nothing anywhere).