2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-14 18:42:33 +03:00

Refactored AxiosError to a constructor;

Refactored `Cancel` to a constructor, a subclass of the `AxiosError`;
Expose CanceledError class;
Refactored axios error codes;
Added `toFlatObject` util;
This commit is contained in:
DigitalBrainJS
2021-10-14 18:53:46 +03:00
parent 1025d1231a
commit 7f1236652a
29 changed files with 332 additions and 221 deletions
+3 -2
View File
@@ -9,6 +9,7 @@ var fs = require('fs');
var path = require('path');
var pkg = require('./../../../package.json');
var server, proxy;
var AxiosError = require('../../../lib/core/AxiosError');
describe('supports http with nodejs', function () {
@@ -51,7 +52,7 @@ describe('supports http with nodejs', function () {
setTimeout(function () {
assert.equal(success, false, 'request should not succeed');
assert.equal(failure, true, 'request should fail');
assert.equal(error.code, 'ERR_PARSE_TIMEOUT');
assert.equal(error.code, AxiosError.ERR_BAD_OPTION_VALUE);
assert.equal(error.message, 'error trying to parse `config.timeout` to int');
done();
}, 300);
@@ -953,7 +954,7 @@ describe('supports http with nodejs', function () {
axios.get('http://localhost:4444/', {
cancelToken: source.token
}).catch(function (thrown) {
assert.ok(thrown instanceof axios.Cancel, 'Promise must be rejected with a Cancel object');
assert.ok(thrown instanceof axios.Cancel, 'Promise must be rejected with a CanceledError object');
assert.equal(thrown.message, 'Operation has been canceled.');
done();
});