intense-visions/harness-engineering/svelte-error-pages
Claude Code and agent skill by intense-visions/harness-engineering
- community
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install intense-visions/harness-engineering/svelte-error-pagesSKILL.md
The same SKILL.md was published earlier as intense-visions/harness-engineering/svelte-error-pages.
Svelte Error Pages
Handle 404s, auth failures, and unexpected crashes in SvelteKit with +error.svelte, the error() helper, and handleError hooks
When to Use
- You need to show a custom error page for 404s, 403s, or other HTTP errors thrown in load functions
- You want to customize the error UI per route segment (nested error boundaries)
- You need to capture unexpected server errors and report them to an error tracking service
- You are unsure when to use
error()vs. throwing raw errors vs. returningfail()
Instructions
Defining error pages:
- Create
+error.sveltein any route directory. It catches errors thrown by the load functions in that route segment and all its children:
- Add nested
+error.sveltefiles for section-specific error UIs. The nearest ancestor+error.sveltecatches the error:
Throwing expected errors:
- Use the
errorhelper from@sveltejs/kitfor expected, anticipated errors (404, 401, 403). These are shown to the user via+error.svelte:
- Pass a structured message object instead of a string for richer error data:
Access in +error.svelte:
Unexpected errors:
- Unhandled exceptions (thrown objects that are not SvelteKit errors) are treated as 500 errors. SvelteKit will NOT expose the error message to the client — only the
handleErrorhook's return value is shown:
Redirecting from error pages:
- Throw
redirectfrom@sveltejs/kitto navigate the user rather than showing an error:
Custom error shape:
- Extend the
App.Errorinterface to add fields to$page.error:
Details
Expected vs. unexpected errors:
| Type | How thrown | User sees | Logged | |
|---|---|---|---|---|
| Expected | throw error(4xx, msg) | The message directly | No (by design) | |
| Unexpected | throw new Error(...) | handleError return value | Yes (via handleError) | |
| Redirect | throw redirect(3xx, url) | Navigation | No |
error() vs. fail():
error()— terminates the load function, shows the+error.sveltepagefail()— only valid in form actions, re-renders the page with error data in theformprop
Never use fail() in load functions; never use error() in actions when you want to re-display the form.
Layout-level errors:
If an error is thrown in a layout load function, the nearest ancestor +error.svelte catches it — not a sibling of the layout. This means errors in (app)/+layout.server.ts render the (app)/+error.svelte, not the root +error.svelte.
The root error page:
The root src/routes/+error.svelte is the last resort. If this page itself throws an error, SvelteKit falls back to a static error page generated from src/error.html (if it exists) or a plain text response.
$page.status:
The $page.status reactive value reflects the HTTP status code of the current page, including error pages. Use it to render different UI for 404 vs. 500 errors.
Source
https://kit.svelte.dev/docs/errors
Process
- Read the instructions and examples in this document.
- Apply the patterns to your implementation, adapting to your specific context.
- Verify your implementation against the details and edge cases listed above.
Harness Integration
- Type: knowledge — this skill is a reference document, not a procedural workflow.
- No tools or state — consumed as context by other skills and agents.
Success Criteria
- The patterns described in this document are applied correctly in the implementation.
- Edge cases and anti-patterns listed in this document are avoided.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingagents/skills/cursor/svelte-error-pages/SKILL.md
Popularity
- Repository stars
- 14
- Repository forks
- 7
- 7-day trend score
- 14
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/intense-visions/harness-engineering/svelte-error-pages)