2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-11 18:02:32 +03:00

Added toJSON to decorated Axios errors to faciliate serialization (#1625)

This commit is contained in:
Tim Johns
2018-08-06 22:33:55 -07:00
committed by Emily Morehouse
parent b4c5d35d28
commit 6b44e80ade
2 changed files with 31 additions and 0 deletions
+18
View File
@@ -17,5 +17,23 @@ module.exports = function enhanceError(error, config, code, request, response) {
}
error.request = request;
error.response = response;
error.toJSON = function() {
return {
// Standard
message: this.message,
name: this.name,
// Microsoft
description: this.description,
number: this.number,
// Mozilla
fileName: this.fileName,
lineNumber: this.lineNumber,
columnNumber: this.columnNumber,
stack: this.stack,
// Axios
config: this.config,
code: this.code
};
};
return error;
};