Skip to content
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

Use AxiosError constructor to create axios errors if available #343

Merged
merged 2 commits into from Aug 10, 2022

Conversation

rstein
Copy link
Contributor

@rstein rstein commented Jul 11, 2022

From v0.27.2 axios uses a constructor to create instances of AxiosError. (See axios/axios#3645). This PR uses said constructor to create errors and falls back to the previous behavior for older versions if the constructor is not available. This also fixes #338

@ckcr4lyf
Copy link

Thanks for this

@Legion2
Copy link

Legion2 commented Aug 9, 2022

What is the timeline for this fix? We are currently forced to implement workarounds in our tests.

@ctimmerm
Copy link
Owner

ctimmerm commented Aug 9, 2022

Tests are failing, I can merge it as soon as they pass.

@ckcr4lyf
Copy link

I might take a gander at fixing the tests tonight, if @rstein isn't around

@rstein
Copy link
Contributor Author

rstein commented Aug 10, 2022

Hi! I have changed the error creation to use the AxiosError.from method. Using new AxiosError seems to cause the stack property to be missing on the error object. Tests are now working for me locally.

@ctimmerm
Copy link
Owner

Thanks!

@ctimmerm ctimmerm merged commit fcebe65 into ctimmerm:master Aug 10, 2022
@rstein rstein deleted the axios-error-constructor branch August 10, 2022 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not compatible with axios version 0.27.2, which is in package.json
4 participants