Errors

API failures use JSON; HTML page failures render an error boundary. SwelteRpcError(status, body, base, fn) replaces thrown error()/json() helpers.

terminal
curl -X POST /api/greet -H 'Accept: application/json' -d '{"fn":"nope"}'
response
{ "error": "unknown fn", "fn": "nope", "path": "/api/greet", "available": ["login"] }
StatusWhen
404unknown @[rpc] fn (+ available list), unknown path, unknown ?q qualifier
400missing "fn", bad JSON, !T failure (err.msg())
405method without handler (DELETE with no @[delete])
413body over SWELTE_BODY_LIMIT (default 10MB)
429over SWELTE_RATE_LIMIT per IP window
500handler over SWELTE_HANDLER_TIMEOUT_MS (default 10s, server stays up)
Env knobs share one rule: unset, invalid, 0, or negative → built-in default. 0 means default, never “off”.

Nested page error boundaries

Place +error.svelte in any route directory, with { status?, message? } props. SSR, hydration, navigation and action errors select the nearest physical ancestor, including route groups.

src/routes
src/routes/+error.svelte             # root fallback
src/routes/+route.svelte             # retained by admin boundary
src/routes/admin/+error.svelte       # nearest admin boundary
src/routes/admin/+route.svelte       # replaced by admin boundary
src/routes/admin/users/+page.svelte  # failing page

The selected boundary replaces its directory's wrapper and page, retaining wrappers strictly above it and their successful native load data. Failed universal loads are not rerun while rendering an error. A broken boundary or retained wrapper falls back to the next ancestor. SSR records its choice so hydration adopts the same tree.

Unknown URLs use matching ungrouped directory scopes, including dynamic segments, then root. Grouped scopes require a matched page. Error components are imported eagerly, independently of page chunking and layout resets. Load/action errors retain their status; page render failures produce a sanitized 500. Missing or failed boundaries preserve the shell fallback.

SPA-first proxy

GET / (no ?q=, no JSON Accept) always serves the page — browser refresh never hits the API. Only JSON Accept, JSON bodies, and form bodies proxy to V. Exact dist/ files win over both.