@sp-api-sdk/common
Version:
Selling Parner API common library
26 lines (25 loc) • 1.02 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.SellingPartnerApiError = void 0;
const node_url_1 = require("node:url");
const axios_1 = require("axios");
class SellingPartnerApiError extends axios_1.AxiosError {
innerMessage;
apiName;
apiVersion;
constructor(error) {
super('Unknown error', error.code, error.config, error.request, error.response);
this.innerMessage = error.message;
if (error.config.url) {
const [apiName, apiVersion] = new node_url_1.URL(error.config.url).pathname.split('/').slice(1);
const apiPrefix = `${apiName} (${apiVersion})`;
this.apiName = apiName;
this.apiVersion = apiVersion;
this.message = error.response
? `${apiPrefix} error: Response code ${error.response.status}`
: `${apiPrefix} error: No response`;
}
this.name = this.constructor.name;
}
}
exports.SellingPartnerApiError = SellingPartnerApiError;
;