-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
feature / enhancementNew feature or requestNew feature or requestready to implementplease submit PRs for these issues!please submit PRs for these issues!
Milestone
Description
Describe the problem
When doing a client-side __data.json request, errors thrown with the error helper function inside hooks.server.ts , will not return the correct error object.
It works as expected when error gets thrown inside a +server.* file.
Here is a demonstration of the issue; https://stackblitz.com/edit/sveltejs-kit-template-default-djcepj?file=src/hooks.server.ts
- start the application
- click on the "test hooks.server.ts" link
- a 401 error gets thrown inside
hooks.servert.ts - the page shows a 500 error
- reload the page
- the 401 error gets correctly shown
related: #7609
The issue was already described as a sidenote there.
Describe the proposed solution
SvelteKit should support throwing error objects also for __data.json requests inside hooks.server.ts.
This makes the usage of the error helper function more consistent.
Alternatives considered
Leave it as it is
Importance
would make my life easier
Additional Information
No response
Metadata
Metadata
Assignees
Labels
feature / enhancementNew feature or requestNew feature or requestready to implementplease submit PRs for these issues!please submit PRs for these issues!