Standardise ServerErrors #200
Closed
DustinJSilk
started this conversation in
Proposals For Qwik
Replies: 3 comments 2 replies
-
Right, that does seem more intuitive. v2 is a good opportunity to make this breaking change @mhevery |
Beta Was this translation helpful? Give feedback.
0 replies
-
@DustinJSilk thanks for the proposal! Want to help us and champion it? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is it about?
ServerErrors should not return a value on the client, they should be thrown, and the error types should be the same for routeLoaders
What's the motivation for this proposal?
Problems you are trying to solve:
ServerError
in aserver$
function allows us to change the status code and payload of the repsonse. On the client, the value of the error is returned, rather than having the client throw the error so that it can be caught. This brings about a few challenges:server$
functions.server$
function has to return a tuple to handle the error path. See the original PR for an example: feat(server$): config argument, optional GET, ServerError qwik#6290server$
function which previously might throw a standard error now also requires changes to how the function is called due to the change in it's signature with a tuple responserouteLoader$
throws an error using the syntaxthrow event.error(500, 'some data')
. This has 2 significant issues:routeLoader$
expects a different error instance to theserver$
.Goals you are trying to achieve:
server$
errors as if they are standard errors on the client.Any other context or information you want to share:
This would be a breaking change, but I dont think this API is widely used currently considering it doesn't work in a dev build due to this error: QwikDev/qwik#7165
This means we might be able to implement this change as a minor version bump, although it would technically be a breaking change.
Proposed Solution / Feature
What do you propose?
server$
androuteLoader$
error types to both use aServerError
class which isn't part of the event object.Code examples
Links / References
Original ServerError PR: QwikDev/qwik#6290
Beta Was this translation helpful? Give feedback.
All reactions