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

Throw original error on network error #78

Merged
merged 1 commit into from
Jun 29, 2021
Merged

Throw original error on network error #78

merged 1 commit into from
Jun 29, 2021

Conversation

jagoda
Copy link
Contributor

@jagoda jagoda commented Jun 29, 2021

Axios errors do not contain a response attribute when there is
no response (ex. network errors).

Axios errors do not contain a `response` attribute when there is
no response (ex. network errors).
@@ -55,7 +55,11 @@ async function axiosFetch (
try {
result = await axios.request(config);
} catch (err) {
result = err.response;
if (err.response) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this change the original error is masked by a new error: TypeError: Cannot read property 'headers' of undefined.. This is because the code below assumes that response is defined and attempts to read attributes from it.

@jagoda jagoda merged commit 61bc070 into master Jun 29, 2021
@jagoda jagoda deleted the fix-exceptions branch June 29, 2021 18:15
@jagoda jagoda mentioned this pull request Jun 29, 2021
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.

None yet

2 participants