UNPKG

@gentrace/core

Version:
1 lines 5.46 kB
{"version":3,"file":"AxiosError.mjs","sources":["AxiosError.js"],"sourcesContent":["'use strict';\nimport utils from '../utils.js';\n/**\n * Create an Error with the specified message, config, error code, request and response.\n *\n * @param {string} message The error message.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [config] The config.\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n *\n * @returns {Error} The created error.\n */\nfunction AxiosError(message, code, config, request, response) {\n Error.call(this);\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n else {\n this.stack = (new Error()).stack;\n }\n this.message = message;\n this.name = 'AxiosError';\n code && (this.code = code);\n config && (this.config = config);\n request && (this.request = request);\n response && (this.response = response);\n}\nutils.inherits(AxiosError, Error, {\n toJSON: function toJSON() {\n return {\n // Standard\n message: this.message,\n name: this.name,\n // Microsoft\n description: this.description,\n number: this.number,\n // Mozilla\n fileName: this.fileName,\n lineNumber: this.lineNumber,\n columnNumber: this.columnNumber,\n stack: this.stack,\n // Axios\n config: utils.toJSONObject(this.config),\n code: this.code,\n status: this.response && this.response.status ? this.response.status : null\n };\n }\n});\nconst prototype = AxiosError.prototype;\nconst descriptors = {};\n[\n 'ERR_BAD_OPTION_VALUE',\n 'ERR_BAD_OPTION',\n 'ECONNABORTED',\n 'ETIMEDOUT',\n 'ERR_NETWORK',\n 'ERR_FR_TOO_MANY_REDIRECTS',\n 'ERR_DEPRECATED',\n 'ERR_BAD_RESPONSE',\n 'ERR_BAD_REQUEST',\n 'ERR_CANCELED',\n 'ERR_NOT_SUPPORT',\n 'ERR_INVALID_URL'\n // eslint-disable-next-line func-names\n].forEach(code => {\n descriptors[code] = { value: code };\n});\nObject.defineProperties(AxiosError, descriptors);\nObject.defineProperty(prototype, 'isAxiosError', { value: true });\n// eslint-disable-next-line func-names\nAxiosError.from = (error, code, config, request, response, customProps) => {\n const axiosError = Object.create(prototype);\n utils.toFlatObject(error, axiosError, function filter(obj) {\n return obj !== Error.prototype;\n }, prop => {\n return prop !== 'isAxiosError';\n });\n AxiosError.call(axiosError, error.message, code, config, request, response);\n axiosError.cause = error;\n axiosError.name = error.name;\n customProps && Object.assign(axiosError, customProps);\n return axiosError;\n};\nexport default AxiosError;\n"],"names":[],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE;AAC9D,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrB,IAAI,IAAI,KAAK,CAAC,iBAAiB,EAAE;AACjC,QAAQ,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;AACxD,KAAK;AACL,SAAS;AACT,QAAQ,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,EAAE,EAAE,KAAK,CAAC;AACzC,KAAK;AACL,IAAI,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AAC3B,IAAI,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;AAC7B,IAAI,IAAI,KAAK,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AAC/B,IAAI,MAAM,KAAK,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;AACrC,IAAI,OAAO,KAAK,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC;AACxC,IAAI,QAAQ,KAAK,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;AAC3C,CAAC;AACD,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,EAAE;AAClC,IAAI,MAAM,EAAE,SAAS,MAAM,GAAG;AAC9B,QAAQ,OAAO;AACf;AACA,YAAY,OAAO,EAAE,IAAI,CAAC,OAAO;AACjC,YAAY,IAAI,EAAE,IAAI,CAAC,IAAI;AAC3B;AACA,YAAY,WAAW,EAAE,IAA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