UNPKG

stellar-plus

Version:

beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain

39 lines (38 loc) 1.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractAxiosErrorInfo = exports.AxiosErrorTypes = void 0; var AxiosErrorTypes; (function (AxiosErrorTypes) { AxiosErrorTypes["AxiosResponseError"] = "AxiosResponseError"; AxiosErrorTypes["AxiosRequestError"] = "AxiosRequestError"; AxiosErrorTypes["UnknownError"] = "UnknownError"; })(AxiosErrorTypes || (exports.AxiosErrorTypes = AxiosErrorTypes = {})); const extractAxiosErrorInfo = (error) => { var _a, _b; if (error.response) { return { type: AxiosErrorTypes.AxiosResponseError, message: error.message, code: error.code, status: error.response.status, statusText: error.response.statusText, data: error.response.data, url: (_a = error.config) === null || _a === void 0 ? void 0 : _a.url, }; } else if (error.request) { return { type: AxiosErrorTypes.AxiosRequestError, message: 'No response received', request: error.request, url: (_b = error.config) === null || _b === void 0 ? void 0 : _b.url, }; } else { return { type: AxiosErrorTypes.UnknownError, message: error.message || 'An unknown error occurred', }; } }; exports.extractAxiosErrorInfo = extractAxiosErrorInfo;