CoolFace
Apppublic

opusdev/vector-similarity-api

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
AxiosError.js74 linesDownload Raw Back to core
1'use strict';2 3import utils from '../utils.js';4 5class AxiosError extends Error {6    static from(error, code, config, request, response, customProps) {7        const axiosError = new AxiosError(error.message, code || error.code, config, request, response);8        axiosError.cause = error;9        axiosError.name = error.name;10        customProps && Object.assign(axiosError, customProps);11        return axiosError;12    }13 14    /**15     * Create an Error with the specified message, config, error code, request and response.16     *17     * @param {string} message The error message.18     * @param {string} [code] The error code (for example, 'ECONNABORTED').19     * @param {Object} [config] The config.20     * @param {Object} [request] The request.21     * @param {Object} [response] The response.22     *23     * @returns {Error} The created error.24     */25    constructor(message, code, config, request, response) {26        super(message);27        this.name = 'AxiosError';28        this.isAxiosError = true;29        code && (this.code = code);30        config && (this.config = config);31        request && (this.request = request);32        if (response) {33            this.response = response;34            this.status = response.status;35        }36    }37 38    toJSON() {39        return {40            // Standard41            message: this.message,42            name: this.name,43            // Microsoft44            description: this.description,45            number: this.number,46            // Mozilla47            fileName: this.fileName,48            lineNumber: this.lineNumber,49            columnNumber: this.columnNumber,50            stack: this.stack,51            // Axios52            config: utils.toJSONObject(this.config),53            code: this.code,54            status: this.status,55        };56    }57}58 59// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.60AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';61AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';62AxiosError.ECONNABORTED = 'ECONNABORTED';63AxiosError.ETIMEDOUT = 'ETIMEDOUT';64AxiosError.ERR_NETWORK = 'ERR_NETWORK';65AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';66AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';67AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';68AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';69AxiosError.ERR_CANCELED = 'ERR_CANCELED';70AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';71AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';72 73export default AxiosError;74