@shapediver/sdk.geometry-api-sdk-v2
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -9,3 +9,3 @@ import { RawAxiosRequestConfig } from 'axios'; | ||
export declare class Configuration extends ClientConfig { | ||
protected readonly sdkVersion = "2.1.0"; | ||
protected readonly sdkVersion = "2.2.0"; | ||
readonly useCustomAxios: boolean; | ||
@@ -12,0 +12,0 @@ readonly maxRetries: number; |
@@ -9,3 +9,3 @@ "use strict"; | ||
super(param); | ||
this.sdkVersion = '2.1.0'; | ||
this.sdkVersion = '2.2.0'; | ||
this.useCustomAxios = (_a = param.useCustomAxios) !== null && _a !== void 0 ? _a : true; | ||
@@ -12,0 +12,0 @@ this.maxRetries = (_b = param.maxRetries) !== null && _b !== void 0 ? _b : 5; |
import { ResErrorType } from './client'; | ||
export declare class SdError extends Error { | ||
constructor(message: string); | ||
export declare class SdGeometryError extends Error { | ||
constructor(message?: string); | ||
} | ||
export declare class SdRequestError extends Error { | ||
export declare class RequestError extends SdGeometryError { | ||
constructor(message: string); | ||
} | ||
export declare class SdResponseError extends Error { | ||
export declare class ResponseError extends SdGeometryError { | ||
readonly status: number; | ||
@@ -14,7 +14,7 @@ readonly type: ResErrorType; | ||
} | ||
export declare class IllegalArgumentError extends Error { | ||
export declare class IllegalArgumentError extends SdGeometryError { | ||
field: string; | ||
constructor(field: string, msg?: string); | ||
} | ||
export declare class TimeoutError extends Error { | ||
export declare class TimeoutError extends SdGeometryError { | ||
field: string; | ||
@@ -21,0 +21,0 @@ constructor(field: string, msg?: string); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TimeoutError = exports.IllegalArgumentError = exports.SdResponseError = exports.SdRequestError = exports.SdError = void 0; | ||
exports.TimeoutError = exports.IllegalArgumentError = exports.ResponseError = exports.RequestError = exports.SdGeometryError = void 0; | ||
const client_1 = require("./client"); | ||
class SdError extends Error { | ||
class SdGeometryError extends Error { | ||
constructor(message) { | ||
super(message); | ||
this.name = 'SdError'; | ||
this.name = 'SdGeometryError'; | ||
} | ||
} | ||
exports.SdError = SdError; | ||
class SdRequestError extends Error { | ||
exports.SdGeometryError = SdGeometryError; | ||
class RequestError extends SdGeometryError { | ||
constructor(message) { | ||
super(message); | ||
this.name = 'SdRequestError'; | ||
this.name = 'RequestError'; | ||
} | ||
} | ||
exports.SdRequestError = SdRequestError; | ||
class SdResponseError extends Error { | ||
exports.RequestError = RequestError; | ||
class ResponseError extends SdGeometryError { | ||
constructor(status, message, desc, type) { | ||
super(message); | ||
this.name = 'SdResponseError'; | ||
this.name = 'ResponseError'; | ||
this.status = status; | ||
@@ -31,4 +31,4 @@ this.description = desc; | ||
} | ||
exports.SdResponseError = SdResponseError; | ||
class IllegalArgumentError extends Error { | ||
exports.ResponseError = ResponseError; | ||
class IllegalArgumentError extends SdGeometryError { | ||
constructor(field, msg) { | ||
@@ -41,3 +41,3 @@ super(msg); | ||
exports.IllegalArgumentError = IllegalArgumentError; | ||
class TimeoutError extends Error { | ||
class TimeoutError extends SdGeometryError { | ||
constructor(field, msg) { | ||
@@ -44,0 +44,0 @@ super(msg); |
import { AxiosError, AxiosPromise } from 'axios'; | ||
import { SdError, SdRequestError, SdResponseError } from './error'; | ||
import { RequestError, ResponseError } from './error'; | ||
export declare function sleep(ms: number): Promise<void>; | ||
@@ -11,3 +11,3 @@ export declare function extractFileInfo(headers: Record<string, any> | undefined): { | ||
export declare function exists(apiCall: () => AxiosPromise<unknown>): Promise<boolean>; | ||
export declare function processError(error: AxiosError | Error): SdError | SdRequestError | SdResponseError; | ||
export declare function processError(error: AxiosError | Error): Error | RequestError | ResponseError; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -80,15 +80,15 @@ "use strict"; | ||
typeof data.message === 'string') { | ||
return new error_1.SdResponseError(status, data.message, data.desc, data.error); | ||
return new error_1.ResponseError(status, data.message, data.desc, data.error); | ||
} | ||
else { | ||
return new error_1.SdResponseError(status, err.message, 'No error description provided'); | ||
return new error_1.ResponseError(status, err.message, 'No error description provided'); | ||
} | ||
} | ||
else if ('request' in error) { | ||
return new error_1.SdRequestError(error.message); | ||
return new error_1.RequestError(error.message); | ||
} | ||
else { | ||
return new error_1.SdError(error.message); | ||
return error; | ||
} | ||
} | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@shapediver/sdk.geometry-api-sdk-v2", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "SDK to communicate with the Geometry API version 2", | ||
@@ -49,2 +49,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"axios-mock-adapter": "~2.1.0", | ||
"jest": "~29.7.0", | ||
@@ -51,0 +52,0 @@ "lerna": "8.1.8", |
@@ -111,5 +111,5 @@ <p align="center"> | ||
processError, | ||
SdError, | ||
SdRequestError, | ||
SdResponseError, | ||
SdGeometryError, | ||
RequestError, | ||
ResponseError, | ||
} from "@shapediver/sdk.geometry-api-sdk-v2" | ||
@@ -119,19 +119,33 @@ | ||
sdk.model.get("be5d4ce5-f76d-417d-8496-1f038e6f0cab") | ||
catch (err) { | ||
} catch (err) { | ||
const e = processError(err); | ||
if (e instanceof SdRequestError) { | ||
// e is a request error. | ||
// In this case, the request was made but no response was received. | ||
if (e instanceof SdGeometryError) { | ||
/* | ||
* Generic ShapeDiver error. | ||
* | ||
* Generic errors are the base class of all custom ShapeDiver errors, like RequestError, | ||
* ResponseError, IllegalArgumentError, TimeoutError, etc. | ||
* | ||
* Warning: | ||
* Generic Axios errors (non-request/response errors) that are thrown when setting up the | ||
* request are not converted into a SdGeometryError! | ||
*/ | ||
} | ||
if (e instanceof SdResponseError) { | ||
// e is a response error. | ||
// In this case, the request was made and the server responded with a status code that falls | ||
// out of the range of 2xx. | ||
if (e instanceof RequestError) { | ||
/* | ||
* Wrapper around an Axios request error. | ||
* | ||
* In this case, the request was made but no response was received. | ||
*/ | ||
} | ||
if (e instanceof SdError) { | ||
// e is a generic error. | ||
// Generic errors are used for everything that is neither a request error nor a response error. | ||
if (e instanceof ResponseError) { | ||
/* | ||
* Wrapper around an Axios response error. | ||
* | ||
* In this case, the request was made and the server responded with a status code that falls | ||
* out of the range of 2xx. | ||
*/ | ||
} | ||
@@ -138,0 +152,0 @@ } |
@@ -37,3 +37,3 @@ import { RawAxiosRequestConfig } from 'axios'; | ||
export class Configuration extends ClientConfig { | ||
protected readonly sdkVersion = '2.1.0'; // WARNING: This value is updated automatically! | ||
protected readonly sdkVersion = '2.2.0'; // WARNING: This value is updated automatically! | ||
@@ -40,0 +40,0 @@ public readonly useCustomAxios: boolean; |
import { ResErrorType } from './client'; | ||
/** | ||
* Represents a generic (non-request and non-response) error. | ||
* Represents a generic ShapeDiver error. | ||
* | ||
* Something happened in setting up the request that triggered an Error. | ||
* @export | ||
* @class SdError | ||
* @class SdGeometryError | ||
* @extends {Error} | ||
*/ | ||
export class SdError extends Error { | ||
constructor(message: string) { | ||
export class SdGeometryError extends Error { | ||
constructor(message?: string) { | ||
super(message); | ||
this.name = 'SdError'; | ||
this.name = 'SdGeometryError'; | ||
} | ||
@@ -23,9 +23,9 @@ } | ||
* @export | ||
* @class SdRequestError | ||
* @extends {Error} | ||
* @class RequestError | ||
* @extends {SdGeometryError} | ||
*/ | ||
export class SdRequestError extends Error { | ||
export class RequestError extends SdGeometryError { | ||
constructor(message: string) { | ||
super(message); | ||
this.name = 'SdRequestError'; | ||
this.name = 'RequestError'; | ||
} | ||
@@ -40,6 +40,6 @@ } | ||
* @export | ||
* @class SdResponseError | ||
* @extends {Error} | ||
* @class ResponseError | ||
* @extends {SdGeometryError} | ||
*/ | ||
export class SdResponseError extends Error { | ||
export class ResponseError extends SdGeometryError { | ||
/** The HTTP status code from the server response. */ | ||
@@ -56,3 +56,3 @@ public readonly status: number; | ||
super(message); | ||
this.name = 'SdResponseError'; | ||
this.name = 'ResponseError'; | ||
this.status = status; | ||
@@ -70,5 +70,5 @@ this.description = desc; | ||
* @class IllegalArgumentError | ||
* @extends {Error} | ||
* @extends {SdGeometryError} | ||
*/ | ||
export class IllegalArgumentError extends Error { | ||
export class IllegalArgumentError extends SdGeometryError { | ||
constructor( | ||
@@ -86,5 +86,5 @@ public field: string, | ||
* @class TimeoutError | ||
* @extends {Error} | ||
* @extends {SdGeometryError} | ||
*/ | ||
export class TimeoutError extends Error { | ||
export class TimeoutError extends SdGeometryError { | ||
constructor( | ||
@@ -91,0 +91,0 @@ public field: string, |
import { AxiosError, AxiosPromise } from 'axios'; | ||
import { SdError, SdRequestError, SdResponseError } from './error'; | ||
import { RequestError, ResponseError } from './error'; | ||
@@ -96,8 +96,7 @@ /** Delays the response for the given number of milliseconds */ | ||
/** | ||
* Converts a generic Axios error into a more specific ShapeDiver error. | ||
* Tries to convert a generic Axios error into a more specific ShapeDiver error. When no match is | ||
* found, the original error is returned instead. | ||
* @param error The Axios error to convert. | ||
*/ | ||
export function processError( | ||
error: AxiosError | Error | ||
): SdError | SdRequestError | SdResponseError { | ||
export function processError(error: AxiosError | Error): Error | RequestError | ResponseError { | ||
if ('response' in error) { | ||
@@ -118,11 +117,11 @@ const err = error as AxiosError, | ||
) { | ||
return new SdResponseError(status, data.message, data.desc, data.error); | ||
return new ResponseError(status, data.message, data.desc, data.error); | ||
} else { | ||
return new SdResponseError(status, err.message, 'No error description provided'); | ||
return new ResponseError(status, err.message, 'No error description provided'); | ||
} | ||
} else if ('request' in error) { | ||
return new SdRequestError(error.message); | ||
return new RequestError(error.message); | ||
} else { | ||
return new SdError(error.message); | ||
return error; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1236419
246
9
20754