jordy 0.14.3 → 0.14.4
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.
|
@@ -8,7 +8,7 @@ var HttpRestError = (function (_super) {
|
|
|
8
8
|
_this._url = '';
|
|
9
9
|
_this._rawData = null;
|
|
10
10
|
if (typeof arg1 === 'number') {
|
|
11
|
-
_this._errorType =
|
|
11
|
+
_this._errorType = HttpRestError.toErrorType(arg1);
|
|
12
12
|
return _this;
|
|
13
13
|
}
|
|
14
14
|
if (HttpRestError.isHttpRestErrorType(arg1)) {
|
|
@@ -23,7 +23,7 @@ var HttpRestError = (function (_super) {
|
|
|
23
23
|
}
|
|
24
24
|
if (typeof arg1 !== 'string' && arg1) {
|
|
25
25
|
_this._url = arg1.url || '';
|
|
26
|
-
_this._errorType =
|
|
26
|
+
_this._errorType = HttpRestError.toErrorType(arg1.status);
|
|
27
27
|
_this._rawData = arg1.rawData;
|
|
28
28
|
}
|
|
29
29
|
return _this;
|
|
@@ -49,7 +49,15 @@ var HttpRestError = (function (_super) {
|
|
|
49
49
|
enumerable: false,
|
|
50
50
|
configurable: true
|
|
51
51
|
});
|
|
52
|
-
HttpRestError.prototype.
|
|
52
|
+
HttpRestError.prototype.toPlainObject = function () {
|
|
53
|
+
return {
|
|
54
|
+
message: this.message,
|
|
55
|
+
errorType: this._errorType,
|
|
56
|
+
url: this._url,
|
|
57
|
+
rawData: this._rawData,
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
HttpRestError.toErrorType = function (status) {
|
|
53
61
|
if (status === 401) {
|
|
54
62
|
return 'auth';
|
|
55
63
|
}
|
|
@@ -62,19 +70,11 @@ var HttpRestError = (function (_super) {
|
|
|
62
70
|
if (status >= 500) {
|
|
63
71
|
return 'server';
|
|
64
72
|
}
|
|
65
|
-
if (status < 500) {
|
|
73
|
+
if (status >= 400 && status < 500) {
|
|
66
74
|
return 'badRequest';
|
|
67
75
|
}
|
|
68
76
|
return 'unknown';
|
|
69
77
|
};
|
|
70
|
-
HttpRestError.prototype.toPlainObject = function () {
|
|
71
|
-
return {
|
|
72
|
-
message: this.message,
|
|
73
|
-
errorType: this._errorType,
|
|
74
|
-
url: this._url,
|
|
75
|
-
rawData: this._rawData,
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
78
|
HttpRestError.isHttpRestErrorType = function (value) {
|
|
79
79
|
var dic = {
|
|
80
80
|
unknown: true,
|
|
@@ -28,8 +28,8 @@ export declare class HttpRestError extends Error implements HttpRestErrorLike {
|
|
|
28
28
|
constructor(message: string, statusCode: number);
|
|
29
29
|
constructor(message: string, meta: HttpRestErrorMetaArgs);
|
|
30
30
|
constructor(message: string, meta: HttpRestErrorLike);
|
|
31
|
-
toErrorType(status: number): HttpRestErrorType;
|
|
32
31
|
toPlainObject(): HttpRestErrorLike;
|
|
32
|
+
static toErrorType(status: number): HttpRestErrorType;
|
|
33
33
|
static isHttpRestErrorType(value: unknown): value is HttpRestErrorType;
|
|
34
34
|
static isErrorLike(error: unknown): error is ErrorLike;
|
|
35
35
|
static isHttpRestErrorLike(error: unknown): error is HttpRestErrorLike;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jordy",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.4",
|
|
4
4
|
"description": "typescript based frontend toolkit",
|
|
5
5
|
"main": "./esm5/index.js",
|
|
6
6
|
"module": "./esm5/index.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"tslib": "^2.3.1",
|
|
53
53
|
"typescript": "^4.7.4",
|
|
54
54
|
"vite": "^3.0.2",
|
|
55
|
-
"vitest": "^0.
|
|
55
|
+
"vitest": "^0.22.1"
|
|
56
56
|
},
|
|
57
57
|
"files": [
|
|
58
58
|
"esm5/**/*.js",
|