0Pricing
Sveltejs Academy · Lesson

Expected vs Unexpected Errors

Distinguish user-facing expected errors from unexpected server errors.

Two Categories

SvelteKit distinguishes expected errors (thrown intentionally) from unexpected errors (bugs).

Expected: error()

Call error(status, message) for known failure cases.

if (!post) error(404, "Post not found");

All lessons in this course

  1. +error.svelte for Custom Error Pages
  2. Expected vs Unexpected Errors
  3. error() and redirect() Helpers
  4. Error Pages in Nested Layouts
← Back to Sveltejs Academy