Errors and redirects / Basics • Svelte Tutorial
An expected error is one that was created with the error helper from @sveltejs/kit, as in src/routes/expected/+page.server.js: Any other error — such as the one in src/routes/unexpected/+page.server.js — is treated as unexpected: When you throw an expected error, you're telling SvelteKit 'don't worry, I know what I'm doing here'. An unexpected error, by contrast, is assumed to be a bug in your app. When an unexpected error is thrown, its message and stack trace will be logged to the console. In a later chapter we'll learn about how to add custom error handling using the handleError hook. If you click the links in this app, you'll notice an important difference: the expected error message is shown to the user, whereas the unexpected error message is redacted and replaced with a generic 'Internal Error' message and a 500 status code. That's because error messages can contain sensitive data. Next: Error pages
Errors and redirects / Basics • Svelte Tutorial Skip to main content Tutorial Packages Playground Blog Basic Svelte Introduction Welcome to Svelte Your first component Dynamic attributes Styling Nested components HTML tags Reactivity State Deep state Derived state Inspecting state Effects Universal reactivity Props Declaring props Default values Spread props Logic If blocks Else blocks Else-if blocks Each blocks Keyed each blocks Await blocks Events DOM events Inline handlers Capturing Component events Spreading events Bindings Text inputs Numeric inputs Checkbox inputs Select bindings Group i
Explore this link on the map →related reading
- Getting Started: Error Handling | Next.jsnextjs.org
- Configuration • SvelteKit Docssvelte.dev
- How Notion pulled itself back from the brink of failure | Figma Blogfigma.com
- Introduction / What is SvelteKit? • Svelte Tutoriallearn.svelte.dev
- Forms / Validation • Svelte Tutoriallearn.svelte.dev
- Svelte tutorial note | sung.codessung.codes
- Error Boundaries in React - Handling Errors Gracefully | Refinerefine.dev
- Hooks / handleFetch • Svelte Tutoriallearn.svelte.dev
- Introduction / HTML tags • Svelte Tutoriallearn.svelte.dev
- Web standards • SvelteKit Docskit.svelte.dev
- Shared modules / The $lib alias • Svelte Tutoriallearn.svelte.dev
- Overview • Svelte Docssvelte-5-preview.vercel.app