@shapediver/sdk.geometry-api-sdk-v2 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -14
- package/dist/configuration.d.ts +1 -1
- package/dist/configuration.js +1 -1
- package/dist/error.d.ts +6 -6
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +12 -12
- package/dist/error.js.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +4 -4
- package/dist/utils.js.map +1 -1
- package/package.json +2 -1
- package/src/configuration.ts +1 -1
- package/src/error.ts +17 -17
- package/src/utils.ts +8 -9
package/README.md
CHANGED
|
@@ -108,30 +108,44 @@ The SDK provides a helper function to extract ShapeDiver error information from
|
|
|
108
108
|
```typescript
|
|
109
109
|
import {
|
|
110
110
|
processError,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
SdGeometryError,
|
|
112
|
+
RequestError,
|
|
113
|
+
ResponseError,
|
|
114
114
|
} from "@shapediver/sdk.geometry-api-sdk-v2"
|
|
115
115
|
|
|
116
116
|
try {
|
|
117
117
|
sdk.model.get("be5d4ce5-f76d-417d-8496-1f038e6f0cab")
|
|
118
|
-
catch (err) {
|
|
118
|
+
} catch (err) {
|
|
119
119
|
const e = processError(err);
|
|
120
120
|
|
|
121
|
-
if (e instanceof
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
if (e instanceof SdGeometryError) {
|
|
122
|
+
/*
|
|
123
|
+
* Generic ShapeDiver error.
|
|
124
|
+
*
|
|
125
|
+
* Generic errors are the base class of all custom ShapeDiver errors, like RequestError,
|
|
126
|
+
* ResponseError, IllegalArgumentError, TimeoutError, etc.
|
|
127
|
+
*
|
|
128
|
+
* Warning:
|
|
129
|
+
* Generic Axios errors (non-request/response errors) that are thrown when setting up the
|
|
130
|
+
* request are not converted into a SdGeometryError!
|
|
131
|
+
*/
|
|
124
132
|
}
|
|
125
133
|
|
|
126
|
-
if (e instanceof
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
if (e instanceof RequestError) {
|
|
135
|
+
/*
|
|
136
|
+
* Wrapper around an Axios request error.
|
|
137
|
+
*
|
|
138
|
+
* In this case, the request was made but no response was received.
|
|
139
|
+
*/
|
|
130
140
|
}
|
|
131
141
|
|
|
132
|
-
if (e instanceof
|
|
133
|
-
|
|
134
|
-
|
|
142
|
+
if (e instanceof ResponseError) {
|
|
143
|
+
/*
|
|
144
|
+
* Wrapper around an Axios response error.
|
|
145
|
+
*
|
|
146
|
+
* In this case, the request was made and the server responded with a status code that falls
|
|
147
|
+
* out of the range of 2xx.
|
|
148
|
+
*/
|
|
135
149
|
}
|
|
136
150
|
}
|
|
137
151
|
```
|
package/dist/configuration.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface ConfigurationParameters extends Pick<ClientConfigParams, 'acces
|
|
|
6
6
|
maxRetries?: number;
|
|
7
7
|
}
|
|
8
8
|
export declare class Configuration extends ClientConfig {
|
|
9
|
-
protected readonly sdkVersion = "2.
|
|
9
|
+
protected readonly sdkVersion = "2.2.0";
|
|
10
10
|
readonly useCustomAxios: boolean;
|
|
11
11
|
readonly maxRetries: number;
|
|
12
12
|
constructor(param?: ConfigurationParameters);
|
package/dist/configuration.js
CHANGED
|
@@ -6,7 +6,7 @@ class Configuration extends configuration_1.Configuration {
|
|
|
6
6
|
constructor(param = {}) {
|
|
7
7
|
var _a, _b, _c, _d;
|
|
8
8
|
super(param);
|
|
9
|
-
this.sdkVersion = '2.
|
|
9
|
+
this.sdkVersion = '2.2.0';
|
|
10
10
|
this.useCustomAxios = (_a = param.useCustomAxios) !== null && _a !== void 0 ? _a : true;
|
|
11
11
|
this.maxRetries = (_b = param.maxRetries) !== null && _b !== void 0 ? _b : 5;
|
|
12
12
|
this.baseOptions = (_c = this.baseOptions) !== null && _c !== void 0 ? _c : {};
|
package/dist/error.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { ResErrorType } from './client';
|
|
2
|
-
export declare class
|
|
3
|
-
constructor(message
|
|
2
|
+
export declare class SdGeometryError extends Error {
|
|
3
|
+
constructor(message?: string);
|
|
4
4
|
}
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class RequestError extends SdGeometryError {
|
|
6
6
|
constructor(message: string);
|
|
7
7
|
}
|
|
8
|
-
export declare class
|
|
8
|
+
export declare class ResponseError extends SdGeometryError {
|
|
9
9
|
readonly status: number;
|
|
10
10
|
readonly type: ResErrorType;
|
|
11
11
|
readonly description: string;
|
|
12
12
|
constructor(status: number, message: string, desc: string, type?: string);
|
|
13
13
|
}
|
|
14
|
-
export declare class IllegalArgumentError extends
|
|
14
|
+
export declare class IllegalArgumentError extends SdGeometryError {
|
|
15
15
|
field: string;
|
|
16
16
|
constructor(field: string, msg?: string);
|
|
17
17
|
}
|
|
18
|
-
export declare class TimeoutError extends
|
|
18
|
+
export declare class TimeoutError extends SdGeometryError {
|
|
19
19
|
field: string;
|
|
20
20
|
constructor(field: string, msg?: string);
|
|
21
21
|
}
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAUxC,qBAAa,
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAUxC,qBAAa,eAAgB,SAAQ,KAAK;gBAC1B,OAAO,CAAC,EAAE,MAAM;CAI/B;AAUD,qBAAa,YAAa,SAAQ,eAAe;gBACjC,OAAO,EAAE,MAAM;CAI9B;AAWD,qBAAa,aAAc,SAAQ,eAAe;IAE9C,SAAgB,MAAM,EAAE,MAAM,CAAC;IAG/B,SAAgB,IAAI,EAAE,YAAY,CAAC;IAGnC,SAAgB,WAAW,EAAE,MAAM,CAAC;gBAExB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAU3E;AAOD,qBAAa,oBAAqB,SAAQ,eAAe;IAE1C,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,MAAM;CAKnB;AAOD,qBAAa,YAAa,SAAQ,eAAe;IAElC,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,MAAM;CAKnB"}
|
package/dist/error.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TimeoutError = exports.IllegalArgumentError = exports.
|
|
3
|
+
exports.TimeoutError = exports.IllegalArgumentError = exports.ResponseError = exports.RequestError = exports.SdGeometryError = void 0;
|
|
4
4
|
const client_1 = require("./client");
|
|
5
|
-
class
|
|
5
|
+
class SdGeometryError extends Error {
|
|
6
6
|
constructor(message) {
|
|
7
7
|
super(message);
|
|
8
|
-
this.name = '
|
|
8
|
+
this.name = 'SdGeometryError';
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
exports.
|
|
12
|
-
class
|
|
11
|
+
exports.SdGeometryError = SdGeometryError;
|
|
12
|
+
class RequestError extends SdGeometryError {
|
|
13
13
|
constructor(message) {
|
|
14
14
|
super(message);
|
|
15
|
-
this.name = '
|
|
15
|
+
this.name = 'RequestError';
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
exports.
|
|
19
|
-
class
|
|
18
|
+
exports.RequestError = RequestError;
|
|
19
|
+
class ResponseError extends SdGeometryError {
|
|
20
20
|
constructor(status, message, desc, type) {
|
|
21
21
|
super(message);
|
|
22
|
-
this.name = '
|
|
22
|
+
this.name = 'ResponseError';
|
|
23
23
|
this.status = status;
|
|
24
24
|
this.description = desc;
|
|
25
25
|
this.type =
|
|
@@ -28,8 +28,8 @@ class SdResponseError extends Error {
|
|
|
28
28
|
: client_1.ResErrorType.UNKNOWN;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
exports.
|
|
32
|
-
class IllegalArgumentError extends
|
|
31
|
+
exports.ResponseError = ResponseError;
|
|
32
|
+
class IllegalArgumentError extends SdGeometryError {
|
|
33
33
|
constructor(field, msg) {
|
|
34
34
|
super(msg);
|
|
35
35
|
this.field = field;
|
|
@@ -37,7 +37,7 @@ class IllegalArgumentError extends Error {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
exports.IllegalArgumentError = IllegalArgumentError;
|
|
40
|
-
class TimeoutError extends
|
|
40
|
+
class TimeoutError extends SdGeometryError {
|
|
41
41
|
constructor(field, msg) {
|
|
42
42
|
super(msg);
|
|
43
43
|
this.field = field;
|
package/dist/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAUxC,MAAa,
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAUxC,MAAa,eAAgB,SAAQ,KAAK;IACtC,YAAY,OAAgB;QACxB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAClC,CAAC;CACJ;AALD,0CAKC;AAUD,MAAa,YAAa,SAAQ,eAAe;IAC7C,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC/B,CAAC;CACJ;AALD,oCAKC;AAWD,MAAa,aAAc,SAAQ,eAAe;IAU9C,YAAY,MAAc,EAAE,OAAe,EAAE,IAAY,EAAE,IAAa;QACpE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,IAAI;YACL,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,qBAAY,CAAC,CAAC,QAAQ,CAAC,IAAoB,CAAC;gBAC9D,CAAC,CAAE,IAAqB;gBACxB,CAAC,CAAC,qBAAY,CAAC,OAAO,CAAC;IACnC,CAAC;CACJ;AApBD,sCAoBC;AAOD,MAAa,oBAAqB,SAAQ,eAAe;IACrD,YACW,KAAa,EACpB,GAAY;QAEZ,KAAK,CAAC,GAAG,CAAC,CAAC;QAHJ,UAAK,GAAL,KAAK,CAAQ;QAIpB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACvC,CAAC;CACJ;AARD,oDAQC;AAOD,MAAa,YAAa,SAAQ,eAAe;IAC7C,YACW,KAAa,EACpB,GAAY;QAEZ,KAAK,CAAC,GAAG,CAAC,CAAC;QAHJ,UAAK,GAAL,KAAK,CAAQ;QAIpB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC/B,CAAC;CACJ;AARD,oCAQC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosError, AxiosPromise } from 'axios';
|
|
2
|
-
import {
|
|
2
|
+
import { RequestError, ResponseError } from './error';
|
|
3
3
|
export declare function sleep(ms: number): Promise<void>;
|
|
4
4
|
export declare function extractFileInfo(headers: Record<string, any> | undefined): {
|
|
5
5
|
size: number | undefined;
|
|
@@ -8,5 +8,5 @@ export declare function extractFileInfo(headers: Record<string, any> | undefined
|
|
|
8
8
|
export declare function contentDispositionFromFilename(filename: string): string;
|
|
9
9
|
export declare function filenameFromContentDisposition(contentDisposition: string): string | undefined;
|
|
10
10
|
export declare function exists(apiCall: () => AxiosPromise<unknown>): Promise<boolean>;
|
|
11
|
-
export declare function processError(error: AxiosError | Error):
|
|
11
|
+
export declare function processError(error: AxiosError | Error): Error | RequestError | ResponseError;
|
|
12
12
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGtD,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAOD,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,GAAG;IACvE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAcA;AAOD,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWvE;AAQD,wBAAgB,8BAA8B,CAAC,kBAAkB,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAmB7F;AAUD,wBAAsB,MAAM,CAAC,OAAO,EAAE,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnF;AAOD,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,YAAY,GAAG,aAAa,CAyB5F"}
|
package/dist/utils.js
CHANGED
|
@@ -77,17 +77,17 @@ function processError(error) {
|
|
|
77
77
|
typeof data.error === 'string' &&
|
|
78
78
|
'message' in data &&
|
|
79
79
|
typeof data.message === 'string') {
|
|
80
|
-
return new error_1.
|
|
80
|
+
return new error_1.ResponseError(status, data.message, data.desc, data.error);
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
|
-
return new error_1.
|
|
83
|
+
return new error_1.ResponseError(status, err.message, 'No error description provided');
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
else if ('request' in error) {
|
|
87
|
-
return new error_1.
|
|
87
|
+
return new error_1.RequestError(error.message);
|
|
88
88
|
}
|
|
89
89
|
else {
|
|
90
|
-
return
|
|
90
|
+
return error;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;AAIA,sBAEC;AAOD,0CAiBC;AAOD,wEAWC;AAQD,wEAmBC;AAUD,wBAOC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;AAIA,sBAEC;AAOD,0CAiBC;AAOD,wEAWC;AAQD,wEAmBC;AAUD,wBAOC;AAOD,oCAyBC;AA3HD,mCAAsD;AAGtD,SAAgB,KAAK,CAAC,EAAU;IAC5B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC;AAOD,SAAgB,eAAe,CAAC,OAAwC;IAIpE,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAG9D,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAG,aAAa,CAAC,CAAC,CAAC,Q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AAS,IAAI,KAAK,EAAE,CAAC;QAC5B,OAAO,IAAI,oBAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;SAAM,CAAC;QACJ,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapediver/sdk.geometry-api-sdk-v2",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "SDK to communicate with the Geometry API version 2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shapediver",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"axios": "~1.7.7"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
+
"axios-mock-adapter": "~2.1.0",
|
|
49
50
|
"jest": "~29.7.0",
|
|
50
51
|
"lerna": "8.1.8",
|
|
51
52
|
"typescript": "~5.5.4",
|
package/src/configuration.ts
CHANGED
|
@@ -34,7 +34,7 @@ export interface ConfigurationParameters
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export class Configuration extends ClientConfig {
|
|
37
|
-
protected readonly sdkVersion = '2.
|
|
37
|
+
protected readonly sdkVersion = '2.2.0'; // WARNING: This value is updated automatically!
|
|
38
38
|
|
|
39
39
|
public readonly useCustomAxios: boolean;
|
|
40
40
|
public readonly maxRetries: number;
|
package/src/error.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { ResErrorType } from './client';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Represents a generic
|
|
4
|
+
* Represents a generic ShapeDiver error.
|
|
5
5
|
*
|
|
6
6
|
* Something happened in setting up the request that triggered an Error.
|
|
7
7
|
* @export
|
|
8
|
-
* @class
|
|
8
|
+
* @class SdGeometryError
|
|
9
9
|
* @extends {Error}
|
|
10
10
|
*/
|
|
11
|
-
export class
|
|
12
|
-
constructor(message
|
|
11
|
+
export class SdGeometryError extends Error {
|
|
12
|
+
constructor(message?: string) {
|
|
13
13
|
super(message);
|
|
14
|
-
this.name = '
|
|
14
|
+
this.name = 'SdGeometryError';
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -20,13 +20,13 @@ export class SdError extends Error {
|
|
|
20
20
|
*
|
|
21
21
|
* The request was made but no response was received.
|
|
22
22
|
* @export
|
|
23
|
-
* @class
|
|
24
|
-
* @extends {
|
|
23
|
+
* @class RequestError
|
|
24
|
+
* @extends {SdGeometryError}
|
|
25
25
|
*/
|
|
26
|
-
export class
|
|
26
|
+
export class RequestError extends SdGeometryError {
|
|
27
27
|
constructor(message: string) {
|
|
28
28
|
super(message);
|
|
29
|
-
this.name = '
|
|
29
|
+
this.name = 'RequestError';
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -36,10 +36,10 @@ export class SdRequestError extends Error {
|
|
|
36
36
|
* The request was made and the server responded with a status code that falls out of the range of
|
|
37
37
|
* 2xx.
|
|
38
38
|
* @export
|
|
39
|
-
* @class
|
|
40
|
-
* @extends {
|
|
39
|
+
* @class ResponseError
|
|
40
|
+
* @extends {SdGeometryError}
|
|
41
41
|
*/
|
|
42
|
-
export class
|
|
42
|
+
export class ResponseError extends SdGeometryError {
|
|
43
43
|
/** The HTTP status code from the server response. */
|
|
44
44
|
public readonly status: number;
|
|
45
45
|
|
|
@@ -51,7 +51,7 @@ export class SdResponseError extends Error {
|
|
|
51
51
|
|
|
52
52
|
constructor(status: number, message: string, desc: string, type?: string) {
|
|
53
53
|
super(message);
|
|
54
|
-
this.name = '
|
|
54
|
+
this.name = 'ResponseError';
|
|
55
55
|
this.status = status;
|
|
56
56
|
this.description = desc;
|
|
57
57
|
this.type =
|
|
@@ -64,9 +64,9 @@ export class SdResponseError extends Error {
|
|
|
64
64
|
/**
|
|
65
65
|
* @export
|
|
66
66
|
* @class IllegalArgumentError
|
|
67
|
-
* @extends {
|
|
67
|
+
* @extends {SdGeometryError}
|
|
68
68
|
*/
|
|
69
|
-
export class IllegalArgumentError extends
|
|
69
|
+
export class IllegalArgumentError extends SdGeometryError {
|
|
70
70
|
constructor(
|
|
71
71
|
public field: string,
|
|
72
72
|
msg?: string
|
|
@@ -79,9 +79,9 @@ export class IllegalArgumentError extends Error {
|
|
|
79
79
|
/**
|
|
80
80
|
* @export
|
|
81
81
|
* @class TimeoutError
|
|
82
|
-
* @extends {
|
|
82
|
+
* @extends {SdGeometryError}
|
|
83
83
|
*/
|
|
84
|
-
export class TimeoutError extends
|
|
84
|
+
export class TimeoutError extends SdGeometryError {
|
|
85
85
|
constructor(
|
|
86
86
|
public field: string,
|
|
87
87
|
msg?: string
|
package/src/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosError, AxiosPromise } from 'axios';
|
|
2
|
-
import {
|
|
2
|
+
import { RequestError, ResponseError } from './error';
|
|
3
3
|
|
|
4
4
|
/** Delays the response for the given number of milliseconds */
|
|
5
5
|
export function sleep(ms: number): Promise<void> {
|
|
@@ -93,12 +93,11 @@ export async function exists(apiCall: () => AxiosPromise<unknown>): Promise<bool
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
96
|
+
* Tries to convert a generic Axios error into a more specific ShapeDiver error. When no match is
|
|
97
|
+
* found, the original error is returned instead.
|
|
97
98
|
* @param error The Axios error to convert.
|
|
98
99
|
*/
|
|
99
|
-
export function processError(
|
|
100
|
-
error: AxiosError | Error
|
|
101
|
-
): SdError | SdRequestError | SdResponseError {
|
|
100
|
+
export function processError(error: AxiosError | Error): Error | RequestError | ResponseError {
|
|
102
101
|
if ('response' in error) {
|
|
103
102
|
const err = error as AxiosError,
|
|
104
103
|
status = err.response!.status,
|
|
@@ -114,13 +113,13 @@ export function processError(
|
|
|
114
113
|
'message' in data &&
|
|
115
114
|
typeof data.message === 'string'
|
|
116
115
|
) {
|
|
117
|
-
return new
|
|
116
|
+
return new ResponseError(status, data.message, data.desc, data.error);
|
|
118
117
|
} else {
|
|
119
|
-
return new
|
|
118
|
+
return new ResponseError(status, err.message, 'No error description provided');
|
|
120
119
|
}
|
|
121
120
|
} else if ('request' in error) {
|
|
122
|
-
return new
|
|
121
|
+
return new RequestError(error.message);
|
|
123
122
|
} else {
|
|
124
|
-
return
|
|
123
|
+
return error;
|
|
125
124
|
}
|
|
126
125
|
}
|