Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
334 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
var AxiosError = require('../core/AxiosError'); | ||
var utils = require('../utils'); | ||
|
||
/** | ||
* A `CanceledError` is an object that is thrown when an operation is canceled. | ||
* | ||
* @class | ||
* @param {string=} message The message. | ||
*/ | ||
function CanceledError(message) { | ||
// eslint-disable-next-line no-eq-null,eqeqeq | ||
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED); | ||
this.name = 'CanceledError'; | ||
} | ||
|
||
utils.inherits(CanceledError, AxiosError, { | ||
__CANCEL__: true | ||
}); | ||
|
||
module.exports = CanceledError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
'use strict'; | ||
|
||
var utils = require('../utils'); | ||
|
||
/** | ||
* Create an Error with the specified message, config, error code, request and response. | ||
* | ||
* @param {string} message The error message. | ||
* @param {string} [code] The error code (for example, 'ECONNABORTED'). | ||
* @param {Object} [config] The config. | ||
* @param {Object} [request] The request. | ||
* @param {Object} [response] The response. | ||
* @returns {Error} The created error. | ||
*/ | ||
function AxiosError(message, code, config, request, response) { | ||
Error.call(this); | ||
this.message = message; | ||
this.name = 'AxiosError'; | ||
code && (this.code = code); | ||
config && (this.config = config); | ||
request && (this.request = request); | ||
response && (this.response = response); | ||
} | ||
|
||
utils.inherits(AxiosError, Error, { | ||
toJSON: function toJSON() { | ||
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, | ||
status: this.response && this.response.status ? this.response.status : null | ||
}; | ||
} | ||
}); | ||
|
||
var prototype = AxiosError.prototype; | ||
var descriptors = {}; | ||
|
||
[ | ||
'ERR_BAD_OPTION_VALUE', | ||
'ERR_BAD_OPTION', | ||
'ECONNABORTED', | ||
'ETIMEDOUT', | ||
'ERR_NETWORK', | ||
'ERR_FR_TOO_MANY_REDIRECTS', | ||
'ERR_DEPRECATED', | ||
'ERR_BAD_RESPONSE', | ||
'ERR_BAD_REQUEST', | ||
'ERR_CANCELED' | ||
// eslint-disable-next-line func-names | ||
].forEach(function(code) { | ||
descriptors[code] = {value: code}; | ||
}); | ||
|
||
Object.defineProperties(AxiosError, descriptors); | ||
Object.defineProperty(prototype, 'isAxiosError', {value: true}); | ||
|
||
// eslint-disable-next-line func-names | ||
AxiosError.from = function(error, code, config, request, response, customProps) { | ||
var axiosError = Object.create(prototype); | ||
|
||
utils.toFlatObject(error, axiosError, function filter(obj) { | ||
return obj !== Error.prototype; | ||
}); | ||
|
||
AxiosError.call(axiosError, error.message, code, config, request, response); | ||
|
||
axiosError.name = error.name; | ||
|
||
customProps && Object.assign(axiosError, customProps); | ||
|
||
return axiosError; | ||
}; | ||
|
||
module.exports = AxiosError; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.