-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
[Feature Request] Ability to handle network error easier #62
Comments
NetworkErrors are very browser/platform dependent. But what I can add is a |
I know fetch has different low level implementations on each browser, but I guess it works the same on all browsers at the top level of fetch javascript api: Basically, it rejects the promise if it was not able to retrieve a response from the server, maybe with different messages, but it does not matter. The main goal of my request is "have a handler method on the wretch api to know when a true fetch error occurs, and then be able to do different things, without manually check the presence of the response property in the wretch reject handler. So yes, a Thanks for your work |
📦 Version 1.6.0 has just been released with the feature: https:/elbywan/wretch#fetcherrorcb-error-networkerror-originalrequest-wretcher--any |
Currently, I didn't found any explicit way to handle network error with wretch. Catch network error is very useful on mobile app or desktop app (electron) to give a better feedback to the end user, or trigger some offline stuff if a network issue is detected.
In 1.5.5, I manage network error with this kind of code:
But it's not very straightforward as wretch has accustomed us.
Something like this is probably more "wretch":
I know fetch doesn't give any information about the network error (there is no way to know that the error see above is a
net::ERR_NAME_NOT_RESOLVED
, but it's good to know at less that is a network error, and have a nice way to handle it.Possibly related to this: #56
The text was updated successfully, but these errors were encountered: