mirror of
https://github.com/axios/axios.git
synced 2026-04-12 14:41:55 +08:00
20 lines
514 B
JavaScript
20 lines
514 B
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Update an Error with the specified config, error code, and response.
|
|
*
|
|
* @param {Error} error The error to update.
|
|
* @param {Object} config The config.
|
|
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
@ @param {Object} [response] The response.
|
|
* @returns {Error} The error.
|
|
*/
|
|
module.exports = function enhanceError(error, config, code, response) {
|
|
error.config = config;
|
|
if (code) {
|
|
error.code = code;
|
|
}
|
|
error.response = response;
|
|
return error;
|
|
};
|