error.code missing on Network Error
See original GitHub issueIs 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 with error.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
or ServerError
.
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
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:6 (1 by maintainers)
Top GitHub Comments
Maybe it’s just a feature
See #4209