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AO,QAAU","file":"/npm/@centrapay/axios-verror@1.4.0/axios-verror.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@centrapay/axios-verror@1.4.0/axios-verror.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\n * Copyright 2022 Centrapay\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use strict';\n\n// eslint-disable-next-line node/no-missing-require\nconst VError = require('verror');\n\nfunction formatSummaryDefault(ctx) {\n  const statusPrefix = ctx.status ? `[${ctx.status}] ` : '';\n  const messageSuffix = ctx.message ? ` (${ctx.message})` : '';\n  return `${statusPrefix}${ctx.method} ${ctx.url}${messageSuffix}`;\n}\n\nfunction extractMessageDefault(res) {\n  return res?.data?.message || res?.data?.error?.message;\n}\n\nfunction trimTrailingSlash(s = '') {\n  return s.replace(/\\/$/, '');\n}\n\nfunction trimLeadingSlash(s = '') {\n  return s.replace(/^\\//, '');\n}\n\nfunction formatUrl(config) {\n  if (config.baseURL) {\n    return [trimTrailingSlash(config.baseURL), trimLeadingSlash(config.url)].join('/');\n  }\n  return config.url;\n}\n\nfunction enhanceError(err) {\n  const config = err.config;\n  if (!config) {\n    throw err;\n  }\n  const res = err.response;\n  const method = (config.method || config.type || 'GET').toUpperCase();\n  const url = formatUrl(config);\n  const status = res?.status;\n  const code = err.code;\n  const message = this.extractMessage(res);\n  const errorMessage = this.formatSummary({\n    url,\n    method,\n    status,\n    message,\n  });\n  throw new VError({\n    name: 'HttpRequestFailed',\n    cause: err,\n    info: {\n      axios: {\n        res,\n        method,\n        url,\n        status,\n        message,\n        code,\n        toJSON() {\n          return {\n            method,\n            url,\n            status,\n            message,\n            code,\n          };\n        }\n      },\n    },\n  }, errorMessage);\n}\n\nfunction configure(opts = {}) {\n  const context = {\n    extractMessage: opts.extractMessage || extractMessageDefault,\n    formatSummary: opts.formatSummary || formatSummaryDefault,\n  };\n  return { enhance: enhanceError.bind(context) };\n}\n\nconst AxiosVError = {\n  configure,\n  enhance: configure().enhance,\n};\n\nmodule.exports = AxiosVError;\n"]}