fix: add error result type to preloadData#12579
Conversation
🦋 Changeset detectedLatest commit: 706cbc3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
preloadDatapreloadData
|
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 :)
|
|
preview: https://svelte-dev-git-preview-kit-12579-svelte.vercel.app/ this is an automated message |
|
Hi @PavelNuzhin , can you provide a minimal reproduction along with an expected output compared to actual output? |

fixes #12399
This PR changes the
preloadDatafunction 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 testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits