-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
On an XMLHttpRequest error, expose error message #565
Comments
There's some value in what you're proposing, but see #562 (comment) for more thoughts on the subject. Would |
Sorry for the delay in responding :) I dont know enough to answer your question. In the context of react native, it is. I honestly dont know about other contexts where fetch is used (browser, and others). |
I am a fullstack developer. I work on IOS, Web and NodeJs platforms, I might be of assistance here. This implementation would also be a tremendous benefit to me. I believe errors should not be recreated and concealed as they are in this library, or at least not in the way that it has been done here. (debugging is really difficult if I don't know what the cause of my error is) I can do some digging and make a PR as soon as possible, I will be adding comments here. Would you guys mind checking my comments and telling me what you think while I work on this? |
@dewwwald Thanks for looking into this! I appreciate your notes. |
Closing since there is nothing left actionable for us to do after this discussion. If anyone has ideas how to improve these error messages, PRs welcome. But please consider all the points above. |
I am trying to get a more useful error message out of fetch when there are network errors...
For context: I am using react native, which uses this library internally for its fetch implementation. If I am connecting to a server whose cert is invalid, or have a typo in the server name, its nicer to expose a more descriptive error message to the user. The XMLHttpRequest that react native provides does this, but fetch ignores it and always sends back 'Network request failed'.
I believe this is because: in the fetch constructor the onerror and ontimeout callbacks from the XMLHttpRequest object are wired up like this:
Sadly, no information about what the error was from the XMLHttpRequest object is actually exposed.
Could it be changed to something like this:
The text was updated successfully, but these errors were encountered: