axios-error
Advanced tools
Comparing version 0.7.8 to 0.7.11
@@ -29,2 +29,5 @@ 'use strict';var _util = require('util');var _util2 = _interopRequireDefault(_util);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} | ||
this.response = response; | ||
if (response && response.status) { | ||
this.status = response.status; | ||
} | ||
} | ||
@@ -31,0 +34,0 @@ |
{ | ||
"name": "axios-error", | ||
"description": "An axios error wrapper that aim to provide clear error message to the user", | ||
"version": "0.7.8", | ||
"version": "0.7.11", | ||
"engines": { | ||
@@ -23,3 +23,3 @@ "node": ">=6" | ||
}, | ||
"gitHead": "9bcc48ddb1c03d7fc0d883c5c8e0e5421cc3a505" | ||
"gitHead": "8e43618226e9c46216372b813d24cae3bdf9ed9e" | ||
} |
@@ -0,1 +1,3 @@ | ||
import util from 'util'; | ||
import MockAdapter from 'axios-mock-adapter'; | ||
@@ -32,6 +34,19 @@ import axios from 'axios'; | ||
expect(error.inspect()).toMatchSnapshot(); | ||
expect(error[util.inspect.custom]()).toMatchSnapshot(); | ||
} | ||
}); | ||
it('should set `.status` property', async () => { | ||
try { | ||
await axios.post('/', { x: 1 }); | ||
} catch (err) { | ||
// overwrite because axios-mock-adapter set it to undefined | ||
err.response.statusText = 'Bad Request'; | ||
const error = new AxiosError(err); | ||
expect(error.status).toBe(400); | ||
} | ||
}); | ||
it('should work with construct using error instance only', async () => { | ||
@@ -49,3 +64,3 @@ try { | ||
expect(error.inspect()).toMatchSnapshot(); | ||
expect(error[util.inspect.custom]()).toMatchSnapshot(); | ||
} | ||
@@ -67,3 +82,3 @@ }); | ||
expect(error.inspect()).toMatchSnapshot(); | ||
expect(error[util.inspect.custom]()).toMatchSnapshot(); | ||
} | ||
@@ -76,3 +91,3 @@ }); | ||
expect(error.inspect()).toMatchSnapshot(); | ||
expect(error[util.inspect.custom]()).toMatchSnapshot(); | ||
}); |
@@ -29,2 +29,5 @@ import util from 'util'; | ||
this.response = response; | ||
if (response && response.status) { | ||
this.status = response.status; | ||
} | ||
} | ||
@@ -31,0 +34,0 @@ |
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
10843
209