Add AxiosException class
See original GitHub issueIs your feature request related to a problem? Please describe. I use typescript. How to verify that I received exactly axios error?
Describe the solution you’d like Add custom error class: AxiosException, which is inherited from the standard Error class
Example
try {
axios.get('...')
}
catch(err) {
if (err instanceof AxiosException) {
console.error(err.response);
}
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:14
- Comments:20 (2 by maintainers)
Top Results From Across the Web
Handling Errors | Axios Docs
{ // The request was made and the server responded with a status code // that falls out of the range of 2xx...
Read more >Handling Errors With Axios - Stack Abuse
In this article, we will see how to handle errors with Axios, as this is very important when making any HTTP calls knowing...
Read more >axios Error typescript, annotation must be 'any' or 'unknown' if?
In typescript, if you want to catch just a specific type of exception, you have to catch whatever is thrown, check if it...
Read more >Axios & Error handling like a boss - DEV Community
It's a awesome way of checking permission, add some header that need to be present, like a token, and preprocess responses, reducing the...
Read more >How to handle API errors in your web app using axios
The second class of errors is where you don't have a response but there's a request field attached to the error. When does...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can apply type guards with the
isAxiosError
helper function.https://github.com/axios/axios/blob/f3ca6371caa738ba5308d413433d9f676f2e0138/index.d.ts#L168
https://github.com/axios/axios/blob/f3ca6371caa738ba5308d413433d9f676f2e0138/test/typescript/axios.ts#L369-L372
@ruscon I think you can use type assertion.