Skip to content
Discussion options

You must be logged in to vote

1. invalid

This one's used for returning validation information in a form action. It's not used in any load functions.
https://kit.svelte.dev/docs/form-actions#anatomy-of-an-action-validation-errors

2. error

You'll want to use throw error(400, "your reason") for expected errors.
For example, 401 Unauthorised when a user fails to log in. You expect this error to happen.

You can use these in a load function or in a +server endpoint for GET, POST, etc.
https://kit.svelte.dev/docs/load#errors

3. redirect

Similar semantics as error.
https://kit.svelte.dev/docs/load#redirects

4. Why throw instead of return?

I'm not smart enough to be in the know, so I'll just make my own assumptions:

  1. It allow…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
2 replies
@DePasqualeOrg
Comment options

@vhscom
Comment options

Answer selected by DePasqualeOrg
Comment options

You must be logged in to vote
5 replies
@eltigerchino
Comment options

@yousufiqbal
Comment options

@dummdidumm
Comment options

@yousufiqbal
Comment options

@joshnuss
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants