Errors
API failures use JSON; HTML page failures render an error boundary. SwelteRpcError(status, body, base, fn) replaces thrown error()/json() helpers.
curl -X POST /api/greet -H 'Accept: application/json' -d '{"fn":"nope"}'{ "error": "unknown fn", "fn": "nope", "path": "/api/greet", "available": ["login"] }| Status | When |
|---|---|
| 404 | unknown @[rpc] fn (+ available list), unknown path, unknown ?q qualifier |
| 400 | missing "fn", bad JSON, !T failure (err.msg()) |
| 405 | method without handler (DELETE with no @[delete]) |
| 413 | body over SWELTE_BODY_LIMIT (default 10MB) |
| 429 | over SWELTE_RATE_LIMIT per IP window |
| 500 | handler over SWELTE_HANDLER_TIMEOUT_MS (default 10s, server stays up) |
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/+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 pageThe 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.