Currently, if you use axios with async / await, you get a stack trace like this:
Request failed with status code 500
at createError (/Users/rmenezes/code/seedfi/web/node_modules/axios/lib/core/createError.js:16:15)
at settle (/Users/rmenezes/code/seedfi/web/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/Users/rmenezes/code/seedfi/web/node_modules/axios/lib/adapters/http.js:237:11)
at IncomingMessage.emit (events.js:208:15)
at IncomingMessage.EventEmitter.emit (domain.js:471:20)
at endReadableNT (_stream_readable.js:1154:12)
at processTicksAndRejections (internal/process/task_queues.js:77:11
It doesn't show you much about what called Axios., which makes debugging quite difficult!
This is because settle calls createError:
https://github.com/axios/axios/blob/master/lib/core/settle.js#L12-L24
Which creates a new error with a brand new stack trace:
https://github.com/axios/axios/blob/master/lib/core/createError.js#L15-L18
Perhaps we can fix this by creating an error before the request goes out and stitching it to the new error's stack trace?
Currently, if you use axios with async / await, you get a stack trace like this:
It doesn't show you much about what called Axios., which makes debugging quite difficult!
This is because
settlecallscreateError:https://github.com/axios/axios/blob/master/lib/core/settle.js#L12-L24
Which creates a new error with a brand new stack trace:
https://github.com/axios/axios/blob/master/lib/core/createError.js#L15-L18
Perhaps we can fix this by creating an error before the request goes out and stitching it to the new error's stack trace?