-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add error result type to preloadData
#12579
base: main
Are you sure you want to change the base?
Conversation
|
preloadData
preloadData
Hello! Thank you for that change! I'm currently testing changes and noticed that the error I throw from the page is always returned as an Internal Error (500) from preloadData(). However, it seems logical that I would see, for example, my error(401, "Test error") from the load() function. This is because when SvelteKit encounters my error in load_route and passes it to handle_error, this check happens:
The error I threw isn't recognized as an HttpError or a SvelteKitError. So the kit can't get its status and always returns Internal Error (500). Here, for example, get_status function will never return my 401 status
Is it intended behavior? Here`s whats happening in handle_error(): Actually i think only problem is that get_status and get_message return default values |
I fixed it for my project. It may be bad but it works for me :)
|
fixes #12399
This PR changes the
preloadData
function so that it returns the 'error' type instead of 'loaded' when the page fails to load. It also returns the error that caused the loading to fail and the correct status (previously it was always 200).EDIT: changed it to also return status for redirects
TODO:
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits