Skip to content

test(AxiosError): document and test error.status behaviour#10725

Merged
jasonsaayman merged 2 commits intoaxios:v1.xfrom
AKIB473:fix/axioserror-status-jsdoc
Apr 15, 2026
Merged

test(AxiosError): document and test error.status behaviour#10725
jasonsaayman merged 2 commits intoaxios:v1.xfrom
AKIB473:fix/axioserror-status-jsdoc

Conversation

@AKIB473
Copy link
Copy Markdown
Contributor

@AKIB473 AKIB473 commented Apr 15, 2026

Summary

Fixes #5330.

error.status is set to response.status when a response is available (4xx/5xx errors), and is undefined for network-level errors that produce no HTTP response. This was already correctly implemented in v1.x but was undocumented and had no direct test coverage.

Changes

  • lib/core/AxiosError.js: add inline comment clarifying when this.status is set vs undefined
  • tests/unit/core/AxiosError.test.js: 4 regression tests covering 4xx, 5xx, network errors (status undefined), and toJSON output

Note

No behaviour change — this is a documentation and test coverage improvement only.


Summary by cubic

Documents and adds regression tests for AxiosError.status. It matches response.status when a response exists and is undefined for network errors; no runtime change.

Description

Testing

  • New tests in tests/unit/core/AxiosError.test.js assert:
    • 4xx/5xx: error.status === response.status.
    • Network errors: error.status is undefined and error.response is absent.
    • toJSON() includes status.

Written for commit 3124138. Summary will update on new commits.

error.status is set to response.status when a response is available,
and is undefined for network-level errors that have no HTTP response.

Add an inline comment in the constructor clarifying this contract, and
add four regression tests for issue axios#5330 covering:
- 4xx errors (error.status === response.status)
- 5xx errors
- network errors (error.status is undefined)
- toJSON includes the status field

Fixes axios#5330
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Copy link
Copy Markdown
Member

@jasonsaayman jasonsaayman left a comment

Choose a reason for hiding this comment

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

Nicely done! 🔥

@jasonsaayman jasonsaayman changed the title fix(AxiosError): document and test error.status behaviour test(AxiosError): document and test error.status behaviour Apr 15, 2026
@jasonsaayman jasonsaayman merged commit e04ee42 into axios:v1.x Apr 15, 2026
22 checks passed
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.

AxiosError type declaration includes a status field, but implementation does not

2 participants