From 09a4422c97153dbb2c7fe8d8fb7ea30d9e669d18 Mon Sep 17 00:00:00 2001 From: Kirill Glazunov Date: Thu, 13 Jul 2023 16:59:17 +0400 Subject: [PATCH 1/2] Improve the network error test for checking `code` property --- test/network_error.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/network_error.spec.js b/test/network_error.spec.js index 493fbc0..9d3967f 100644 --- a/test/network_error.spec.js +++ b/test/network_error.spec.js @@ -22,6 +22,7 @@ describe("networkError spec", function () { function (error) { expect(error.config).to.exist; expect(error.response).to.not.exist; + expect(error.code).to.equal("ERR_NETWORK"); expect(error.message).to.equal("Network Error"); expect(error.isAxiosError).to.be.true; } From 94cf810e28fd6a139eb32b17c8defa4884905685 Mon Sep 17 00:00:00 2001 From: Kirill Glazunov Date: Thu, 13 Jul 2023 16:59:54 +0400 Subject: [PATCH 2/2] Add "ERR_NETWORK" code into point of creating network error --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 0d4bfd1..bae0fa7 100644 --- a/src/index.js +++ b/src/index.js @@ -142,14 +142,14 @@ VERBS.concat("any").forEach(function (method) { networkError: function () { return reply(function (config) { - var error = utils.createAxiosError("Network Error", config); + var error = utils.createAxiosError("Network Error", config, undefined, "ERR_NETWORK"); return Promise.reject(error); }); }, networkErrorOnce: function () { return replyOnce(function (config) { - var error = utils.createAxiosError("Network Error", config); + var error = utils.createAxiosError("Network Error", config, undefined, "ERR_NETWORK"); return Promise.reject(error); }); },