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
error.code missing on Network Error #2351
Comments
@MartinMuzatko i have same issue you reslove this promble? |
@wangfpp it is not a bug report, it is a feature request. |
Hi, It would allow a better error detection for us users (solving or helping to solve issues like #383 , #1296 , #838 , #204 , #2103 ) and libraries (for example axios-retry, as it does here index.js#L9 ). Have a nice day |
I'm also running into this issue. In my case, I want to be able to produce a localized version of the error message, with additional context for the user to understand what happened. Simply comparing the error message for equality with the string 'Network error' seems dodgy. It would also be great if axios could provide any additional information about the underlying error condition. |
See #4209 |
Is your feature request related to a problem? Please describe.
To properly identify errors reliably, I'd like to be able to either compare an error with
instanceof
or alternatively witherror.code
. However, this does not exist on most of the errors.I noticed that when defining a timeout, I get at least a
'ECONNABORTED'
code.Other errors like 404, 403 are also missing this code.
Describe the solution you'd like
I'd have for 400/500 codes the error code of the name of the error, or at least the classification
ClientError
orServerError
.Describe alternatives you've considered
I can also compare the name, but now I need to compile a list of codes,names and whatnot to check whether or not I am connected.
So right now I have
error.code == 'ECONNABORTED' || error.name == 'Network Error'
It would be a lot easier to consume and work with this error if I could e.g. create an array of matching error codes and just check with
includes
.The text was updated successfully, but these errors were encountered: