-
-
Notifications
You must be signed in to change notification settings - Fork 420
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
Handle error codes and failed request in error #1179
Comments
Thanks for the suggestion. I’m a little hesitant to deviate from the default fetch behavior too much, which this library implements. If this library throws, then But to your point, this library is meant to provide better quality of life improvements over the default fetch spec. That’s probably in the form of clearer documentation here. |
I second this, after having used some time debugging why the client middleware In this case my response would never be defined because of the error, which would require a catch handler on every request, or with a custom fetch function in the The latter is what I currently use, but it was not obvious to me, and a more intuitive solution could be to add a middleware option like |
Description
Currently in order to handle errors the code usually looks something like this:
This is because a failed fetch is not getting caught by the library.
Which can also lead to Typescript not liking the new possible return type introduced by the catch.
Proposal
Instead this would be nicer:
I am not sure if I am simply doing something wrong, but having to do error handling twice can complicate things quite a lot.
The downside to this approach is that the previously unhandled errors cannot be typechecked/
However, they need to be handled in both cases anyway.
Checklist
The text was updated successfully, but these errors were encountered: