Description
Describe the problem
The handling of error responses from page endpoints is currently a bit confusing and unflexible.
If a GET page endpoint returns a 4xx or 5xx response, then any props returned in its body
are ignored and the nearest __error.svelte
page is rendered. If body
is an Error
instance, then this (along with its enumerable properties) are available to that page.
If a non-GET page endpoint returns a 4xx or 5xx response, then any props returned in its body
argument are passed to the regular (non-error) page, merged with the GET page endpoint body
props, if any. If body
is an Error
instance, then (I believe) the nearest __error.svelte
page is rendered instead and is sent this error.
Describe the proposed solution
I think it would be nice, whether the user is on a GET or non-GET endpoint, to use the response from the body
- whether it's a POJO or an Error
- to determine whether to render the regular page or the nearest __error.svelte
page, respectively.
I'm not sure what other fallout of this might be.
I'm not sure what we want to do if a page endpoint returns a 4xx/5xx status
but no body
at all. Create a new Error()
whose message is the appropriate description for that HTTP status code?
Alternatives considered
No response
Importance
would make my life easier
Additional Information
No response