2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-23 20:40:40 +03:00

feat(adapter): surface low‑level network error details; attach original error via cause (#6982)

* feat(adapter): surface low‑level network error details; attach original error via `cause`

Node http adapter:
- Promote low-level `err.code` to `AxiosError.code`, prefixing message (e.g. `ECONNREFUSED – …`)
- Keep original error on standard `Error.cause`

XHR adapter:
- Preserve browser `ProgressEvent` on `error.event`
- Use event message when available

Tests:
- Add Node ESM tests under `test/unit/adapters` to assert `code` and `cause` behavior

Types:
- Ensure `AxiosError.cause?: unknown` and `event?: ProgressEvent` are present

* fix(adapter): use fs instead of fs/promises for sync file read in tests to fix GitHub Actions
This commit is contained in:
khani
2025-07-30 11:27:27 +03:30
committed by GitHub
parent 2c2a56ab87
commit 78b290c57c
5 changed files with 111 additions and 15 deletions
Vendored
+2 -1
View File
@@ -418,7 +418,8 @@ export class AxiosError<T = unknown, D = any> extends Error {
isAxiosError: boolean;
status?: number;
toJSON: () => object;
cause?: Error;
cause?: unknown;
event?: BrowserProgressEvent;
static from<T = unknown, D = any>(
error: Error | unknown,
code?: string,