2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00

Updating AxiosError to include stack trace (#4624)

Related to discussions here https://github.com/axios/axios/issues/2387

Attempt to capture the stack trace at the time the error is created in
order to maintain context about where the error originates from.

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Des Preston
2022-05-03 12:46:10 -04:00
committed by GitHub
parent 8213da4f16
commit 7920d11144
2 changed files with 7 additions and 1 deletions
+2 -1
View File
@@ -1,7 +1,7 @@
var AxiosError = require('../../../lib/core/AxiosError');
describe('core::AxiosError', function() {
it('should create an Error with message, config, code, request, response and isAxiosError', function() {
it('should create an Error with message, config, code, request, response, stack and isAxiosError', function() {
var request = { path: '/foo' };
var response = { status: 200, data: { foo: 'bar' } };
var error = new AxiosError('Boom!', 'ESOMETHING', { foo: 'bar' }, request, response);
@@ -12,6 +12,7 @@ describe('core::AxiosError', function() {
expect(error.request).toBe(request);
expect(error.response).toBe(response);
expect(error.isAxiosError).toBe(true);
expect(error.stack).toBeDefined();
});
it('should create an Error that can be serialized to JSON', function() {
// Attempting to serialize request and response results in