@yandex-cloud/axios-wrapper
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -118,6 +118,16 @@ "use strict"; | ||
} | ||
let errorResponse; | ||
if (thrown.response) { | ||
errorResponse = thrown.response; | ||
} | ||
else if (typeof thrown.toJSON === 'function') { | ||
errorResponse = thrown.toJSON(); | ||
} | ||
else { | ||
errorResponse = thrown; | ||
} | ||
if (collectRequest) { | ||
this.collectRequest(Object.assign(Object.assign({}, request), { requestStart, response: thrown.response, error: true, cancelled: axios_1.default.isCancel(thrown), responseError: thrown })); | ||
this.collectRequest(Object.assign(Object.assign({}, request), { requestStart, response: errorResponse, error: true, cancelled: axios_1.default.isCancel(thrown), responseError: thrown })); | ||
} | ||
return this.handleRequestError(thrown.response, () => this.request(Object.assign(Object.assign({}, methodParams), { retries: retries + 1 })), retries, new Error(thrown instanceof Error ? thrown.message : 'Unknown error')); | ||
return this.handleRequestError(errorResponse, () => this.request(Object.assign(Object.assign({}, methodParams), { retries: retries + 1 })), retries, new Error(thrown instanceof Error ? thrown.message : 'Unknown error')); | ||
} | ||
@@ -124,0 +134,0 @@ } |
@@ -115,6 +115,16 @@ import cloneDeep from 'lodash/cloneDeep'; | ||
} | ||
let errorResponse; | ||
if (thrown.response) { | ||
errorResponse = thrown.response; | ||
} | ||
else if (typeof thrown.toJSON === 'function') { | ||
errorResponse = thrown.toJSON(); | ||
} | ||
else { | ||
errorResponse = thrown; | ||
} | ||
if (collectRequest) { | ||
this.collectRequest(Object.assign(Object.assign({}, request), { requestStart, response: thrown.response, error: true, cancelled: axios.isCancel(thrown), responseError: thrown })); | ||
this.collectRequest(Object.assign(Object.assign({}, request), { requestStart, response: errorResponse, error: true, cancelled: axios.isCancel(thrown), responseError: thrown })); | ||
} | ||
return this.handleRequestError(thrown.response, () => this.request(Object.assign(Object.assign({}, methodParams), { retries: retries + 1 })), retries, new Error(thrown instanceof Error ? thrown.message : 'Unknown error')); | ||
return this.handleRequestError(errorResponse, () => this.request(Object.assign(Object.assign({}, methodParams), { retries: retries + 1 })), retries, new Error(thrown instanceof Error ? thrown.message : 'Unknown error')); | ||
} | ||
@@ -121,0 +131,0 @@ } |
# Changelog | ||
## [1.2.2](https://github.com/yandex-cloud/axios-wrapper/compare/v1.2.1...v1.2.2) (2022-07-15) | ||
### Bug Fixes | ||
* correctly handle errors with the missing response ([6b9dc0e](https://github.com/yandex-cloud/axios-wrapper/commit/6b9dc0eab2496aa21cd27e6044b5c6ab235210d1)), closes [#17](https://github.com/yandex-cloud/axios-wrapper/issues/17) | ||
### [1.2.1](https://www.github.com/yandex-cloud/axios-wrapper/compare/v1.2.0...v1.2.1) (2022-04-05) | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "@yandex-cloud/axios-wrapper", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Generic helper class for wrapping axios calls", | ||
@@ -5,0 +5,0 @@ "module": "build/esm/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30028
597