@sp-api-sdk/common
Advanced tools
Comparing version 1.7.13 to 1.7.14
@@ -5,35 +5,19 @@ "use strict"; | ||
const url_1 = require("url"); | ||
class SellingPartnerApiError extends Error { | ||
const axios_1 = require("axios"); | ||
class SellingPartnerApiError extends axios_1.AxiosError { | ||
constructor(error) { | ||
super(); | ||
this.axiosError = error; | ||
this.config = error.config; | ||
this.code = error.code; | ||
this.request = error.request; | ||
this.response = error.response; | ||
this.isAxiosError = error.isAxiosError; | ||
const url = error.config.url ? new url_1.URL(error.config.url) : null; | ||
if (url) { | ||
const [apiName, apiVersion] = url.pathname.split('/').slice(1); | ||
super('Unknown error', error.code, error.config, error.request, error.response); | ||
this.innerMessage = error.message; | ||
if (error.config.url) { | ||
const [apiName, apiVersion] = new 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; | ||
} | ||
get name() { | ||
return this.constructor.name; | ||
} | ||
get message() { | ||
if (this.apiName && this.apiVersion) { | ||
const apiPrefix = `${this.apiName} (${this.apiVersion})`; | ||
if (!this.response) { | ||
return `${apiPrefix} error: No response`; | ||
} | ||
return `${apiPrefix} error: Response code ${this.response.status}`; | ||
} | ||
return 'Unknown error'; | ||
} | ||
toJSON() { | ||
return this.axiosError.toJSON(); | ||
} | ||
} | ||
exports.SellingPartnerApiError = SellingPartnerApiError; |
import { URL } from 'url'; | ||
export class SellingPartnerApiError extends Error { | ||
import { AxiosError } from 'axios'; | ||
export class SellingPartnerApiError extends AxiosError { | ||
constructor(error) { | ||
super(); | ||
this.axiosError = error; | ||
this.config = error.config; | ||
this.code = error.code; | ||
this.request = error.request; | ||
this.response = error.response; | ||
this.isAxiosError = error.isAxiosError; | ||
const url = error.config.url ? new URL(error.config.url) : null; | ||
if (url) { | ||
const [apiName, apiVersion] = url.pathname.split('/').slice(1); | ||
super('Unknown error', error.code, error.config, error.request, error.response); | ||
this.innerMessage = error.message; | ||
if (error.config.url) { | ||
const [apiName, apiVersion] = new 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; | ||
} | ||
get name() { | ||
return this.constructor.name; | ||
} | ||
get message() { | ||
if (this.apiName && this.apiVersion) { | ||
const apiPrefix = `${this.apiName} (${this.apiVersion})`; | ||
if (!this.response) { | ||
return `${apiPrefix} error: No response`; | ||
} | ||
return `${apiPrefix} error: Response code ${this.response.status}`; | ||
} | ||
return 'Unknown error'; | ||
} | ||
toJSON() { | ||
return this.axiosError.toJSON(); | ||
} | ||
} |
@@ -1,15 +0,7 @@ | ||
import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'; | ||
export declare class SellingPartnerApiError<T = any> extends Error implements AxiosError { | ||
config: AxiosRequestConfig; | ||
code?: string; | ||
request?: any; | ||
response?: AxiosResponse<T>; | ||
isAxiosError: boolean; | ||
apiName?: string; | ||
apiVersion?: string; | ||
private readonly axiosError; | ||
constructor(error: AxiosError); | ||
get name(): string; | ||
get message(): string; | ||
toJSON(): object; | ||
import { AxiosError } from 'axios'; | ||
export declare class SellingPartnerApiError<T = unknown, D = any> extends AxiosError<T, D> { | ||
readonly innerMessage: string; | ||
readonly apiName?: string; | ||
readonly apiVersion?: string; | ||
constructor(error: AxiosError<T, D>); | ||
} |
@@ -5,3 +5,3 @@ { | ||
"description": "Selling Parner API common library", | ||
"version": "1.7.13", | ||
"version": "1.7.14", | ||
"main": "dist/cjs/index.js", | ||
@@ -31,5 +31,5 @@ "module": "dist/es/index.js", | ||
"dependencies": { | ||
"@sp-api-sdk/auth": "^1.9.11", | ||
"@sp-api-sdk/auth": "^1.9.12", | ||
"aws4-axios": "^2.4.9", | ||
"axios": "^0.26.1", | ||
"axios": "^0.27.2", | ||
"axios-retry": "^3.2.4", | ||
@@ -59,3 +59,3 @@ "read-pkg-up": "^7.0.1" | ||
}, | ||
"gitHead": "61adb3dd4480de30ba48c20a1da60cebf9d4f0ac" | ||
"gitHead": "e6a6c9da0de5a001da60b1d3f34a3796a3adab0d" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12822
265
+ Addedaxios@0.27.2(transitive)
- Removedaxios@0.26.1(transitive)
Updated@sp-api-sdk/auth@^1.9.12
Updatedaxios@^0.27.2