@nr1e/commons 0.0.2-alpha.13 → 0.0.2-alpha.15
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/errors/errors.d.ts +7 -19
- package/errors/errors.js +1 -14
- package/errors/errors.js.map +1 -1
- package/package.json +1 -1
package/errors/errors.d.ts
CHANGED
|
@@ -5,12 +5,8 @@ interface IError {
|
|
|
5
5
|
message?: string;
|
|
6
6
|
statusCode?: HttpStatusCode | number;
|
|
7
7
|
}
|
|
8
|
-
export interface HttpErrorMessage {
|
|
9
|
-
message: string;
|
|
10
|
-
}
|
|
11
8
|
export interface HttpError extends Error {
|
|
12
9
|
statusCode: HttpStatusCode | number;
|
|
13
|
-
body: HttpErrorMessage;
|
|
14
10
|
}
|
|
15
11
|
/**
|
|
16
12
|
* Checks if the given parameter is an HttpError.
|
|
@@ -29,7 +25,6 @@ export declare function isNotFoundError(e?: IError | null): e is NotFoundError;
|
|
|
29
25
|
*/
|
|
30
26
|
export declare class NotFoundError extends Error implements HttpError {
|
|
31
27
|
readonly statusCode = HttpStatusCode.NOT_FOUND;
|
|
32
|
-
readonly body: HttpErrorMessage;
|
|
33
28
|
constructor(message?: string);
|
|
34
29
|
}
|
|
35
30
|
/**
|
|
@@ -41,9 +36,8 @@ export declare function isForbiddenError(e?: IError | null): e is ForbiddenError
|
|
|
41
36
|
/**
|
|
42
37
|
* Thrown when a requested operations is not allowed.
|
|
43
38
|
*/
|
|
44
|
-
export declare class ForbiddenError extends Error {
|
|
39
|
+
export declare class ForbiddenError extends Error implements HttpError {
|
|
45
40
|
readonly statusCode = HttpStatusCode.FORBIDDEN;
|
|
46
|
-
readonly body: HttpErrorMessage | undefined;
|
|
47
41
|
constructor(message?: string);
|
|
48
42
|
}
|
|
49
43
|
/**
|
|
@@ -55,9 +49,8 @@ export declare function isValidationError(e?: IError | null): e is ValidationErr
|
|
|
55
49
|
/**
|
|
56
50
|
* Thrown when a validation error occurs.
|
|
57
51
|
*/
|
|
58
|
-
export declare class ValidationError extends Error {
|
|
52
|
+
export declare class ValidationError extends Error implements HttpError {
|
|
59
53
|
readonly statusCode = HttpStatusCode.BAD_REQUEST;
|
|
60
|
-
readonly body: HttpErrorMessage | undefined;
|
|
61
54
|
constructor(message?: string);
|
|
62
55
|
}
|
|
63
56
|
/**
|
|
@@ -69,9 +62,8 @@ export declare function isBadRequestError(e?: IError | null): e is BadRequestErr
|
|
|
69
62
|
/**
|
|
70
63
|
* Thrown when a bad request is made.
|
|
71
64
|
*/
|
|
72
|
-
export declare class BadRequestError extends Error {
|
|
65
|
+
export declare class BadRequestError extends Error implements HttpError {
|
|
73
66
|
readonly statusCode = HttpStatusCode.BAD_REQUEST;
|
|
74
|
-
readonly body: HttpErrorMessage | undefined;
|
|
75
67
|
constructor(message?: string);
|
|
76
68
|
}
|
|
77
69
|
/**
|
|
@@ -83,9 +75,8 @@ export declare function isInternalServerError(e?: IError | null): e is InternalS
|
|
|
83
75
|
/**
|
|
84
76
|
* Throws when an internal server error occurs.
|
|
85
77
|
*/
|
|
86
|
-
export declare class InternalServerError extends Error {
|
|
78
|
+
export declare class InternalServerError extends Error implements HttpError {
|
|
87
79
|
readonly statusCode = HttpStatusCode.INTERNAL_SERVER_ERROR;
|
|
88
|
-
readonly body: HttpErrorMessage | undefined;
|
|
89
80
|
constructor(message?: string);
|
|
90
81
|
}
|
|
91
82
|
/**
|
|
@@ -97,9 +88,8 @@ export declare function isConflictError(e?: IError | null): e is ConflictError;
|
|
|
97
88
|
/**
|
|
98
89
|
* Thrown when a conflict occurs.
|
|
99
90
|
*/
|
|
100
|
-
export declare class ConflictError extends Error {
|
|
91
|
+
export declare class ConflictError extends Error implements HttpError {
|
|
101
92
|
readonly statusCode = HttpStatusCode.CONFLICT;
|
|
102
|
-
readonly body: HttpErrorMessage | undefined;
|
|
103
93
|
constructor(message?: string);
|
|
104
94
|
}
|
|
105
95
|
/**
|
|
@@ -111,9 +101,8 @@ export declare function isUnsupportedMediaTypeError(e?: IError | null): e is Uns
|
|
|
111
101
|
/**
|
|
112
102
|
* Thrown when a unsupported media type is used.
|
|
113
103
|
*/
|
|
114
|
-
export declare class UnsupportedMediaTypeError extends Error {
|
|
104
|
+
export declare class UnsupportedMediaTypeError extends Error implements HttpError {
|
|
115
105
|
readonly statusCode = HttpStatusCode.UNSUPPORTED_MEDIA_TYPE;
|
|
116
|
-
readonly body: HttpErrorMessage | undefined;
|
|
117
106
|
constructor(message?: string);
|
|
118
107
|
}
|
|
119
108
|
/**
|
|
@@ -125,9 +114,8 @@ export declare function isNotImplementedError(e?: IError | null): e is NotImplem
|
|
|
125
114
|
/**
|
|
126
115
|
* Thrown when a requested operation is not implemented.
|
|
127
116
|
*/
|
|
128
|
-
export declare class NotImplementedError extends Error {
|
|
117
|
+
export declare class NotImplementedError extends Error implements HttpError {
|
|
129
118
|
readonly statusCode = HttpStatusCode.NOT_IMPLEMENTED;
|
|
130
|
-
readonly body: HttpErrorMessage | undefined;
|
|
131
119
|
readonly expose = true;
|
|
132
120
|
constructor(message?: string);
|
|
133
121
|
}
|
package/errors/errors.js
CHANGED
|
@@ -8,12 +8,7 @@ const http_1 = require("../http");
|
|
|
8
8
|
* @param e the parameter to check
|
|
9
9
|
*/
|
|
10
10
|
function isHttpError(e) {
|
|
11
|
-
return !!(e &&
|
|
12
|
-
e.stack &&
|
|
13
|
-
e.statusCode &&
|
|
14
|
-
e.message &&
|
|
15
|
-
e.name &&
|
|
16
|
-
e.name === 'HttpError');
|
|
11
|
+
return !!(e && e.stack && e.statusCode && e.message && e.name);
|
|
17
12
|
}
|
|
18
13
|
exports.isHttpError = isHttpError;
|
|
19
14
|
/**
|
|
@@ -38,7 +33,6 @@ class NotFoundError extends Error {
|
|
|
38
33
|
message = message !== null && message !== void 0 ? message : 'Not found';
|
|
39
34
|
super(message);
|
|
40
35
|
this.statusCode = http_1.HttpStatusCode.NOT_FOUND;
|
|
41
|
-
this.body = { message };
|
|
42
36
|
this.name = 'NotFoundError';
|
|
43
37
|
}
|
|
44
38
|
}
|
|
@@ -65,7 +59,6 @@ class ForbiddenError extends Error {
|
|
|
65
59
|
message = message !== null && message !== void 0 ? message : 'Forbidden';
|
|
66
60
|
super(message);
|
|
67
61
|
this.statusCode = http_1.HttpStatusCode.FORBIDDEN;
|
|
68
|
-
this.body = { message };
|
|
69
62
|
this.name = 'ForbiddenError';
|
|
70
63
|
}
|
|
71
64
|
}
|
|
@@ -91,7 +84,6 @@ class ValidationError extends Error {
|
|
|
91
84
|
message = message !== null && message !== void 0 ? message : 'Validation error';
|
|
92
85
|
super(message);
|
|
93
86
|
this.statusCode = http_1.HttpStatusCode.BAD_REQUEST;
|
|
94
|
-
this.body = { message };
|
|
95
87
|
this.name = 'ValidationError';
|
|
96
88
|
}
|
|
97
89
|
}
|
|
@@ -117,7 +109,6 @@ class BadRequestError extends Error {
|
|
|
117
109
|
message = message !== null && message !== void 0 ? message : 'Bad request';
|
|
118
110
|
super(message !== null && message !== void 0 ? message : 'Bad request');
|
|
119
111
|
this.statusCode = http_1.HttpStatusCode.BAD_REQUEST;
|
|
120
|
-
this.body = { message };
|
|
121
112
|
this.name = 'BadRequestError';
|
|
122
113
|
}
|
|
123
114
|
}
|
|
@@ -143,7 +134,6 @@ class InternalServerError extends Error {
|
|
|
143
134
|
message = message !== null && message !== void 0 ? message : 'Internal server error';
|
|
144
135
|
super(message);
|
|
145
136
|
this.statusCode = http_1.HttpStatusCode.INTERNAL_SERVER_ERROR;
|
|
146
|
-
this.body = { message };
|
|
147
137
|
this.name = 'InternalServerError';
|
|
148
138
|
}
|
|
149
139
|
}
|
|
@@ -169,7 +159,6 @@ class ConflictError extends Error {
|
|
|
169
159
|
message = message !== null && message !== void 0 ? message : 'Conflict';
|
|
170
160
|
super(message);
|
|
171
161
|
this.statusCode = http_1.HttpStatusCode.CONFLICT;
|
|
172
|
-
this.body = { message };
|
|
173
162
|
this.name = 'ConflictError';
|
|
174
163
|
}
|
|
175
164
|
}
|
|
@@ -195,7 +184,6 @@ class UnsupportedMediaTypeError extends Error {
|
|
|
195
184
|
message = message !== null && message !== void 0 ? message : 'Unsupported media type';
|
|
196
185
|
super(message);
|
|
197
186
|
this.statusCode = http_1.HttpStatusCode.UNSUPPORTED_MEDIA_TYPE;
|
|
198
|
-
this.body = { message };
|
|
199
187
|
this.name = 'UnsupportedMediaTypeError';
|
|
200
188
|
}
|
|
201
189
|
}
|
|
@@ -222,7 +210,6 @@ class NotImplementedError extends Error {
|
|
|
222
210
|
super(message);
|
|
223
211
|
this.statusCode = http_1.HttpStatusCode.NOT_IMPLEMENTED;
|
|
224
212
|
this.expose = true;
|
|
225
|
-
this.body = { message };
|
|
226
213
|
this.name = 'NotImplementedError';
|
|
227
214
|
}
|
|
228
215
|
}
|
package/errors/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["errors.ts"],"names":[],"mappings":";;;AAAA,kCAAuC;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["errors.ts"],"names":[],"mappings":";;;AAAA,kCAAuC;AAavC;;;;GAIG;AACH,SAAgB,WAAW,CAAC,CAAiB;IAC3C,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC;AAFD,kCAEC;AAED;;;;GAIG;AACH,SAAgB,eAAe,CAAC,CAAiB;IAC/C,OAAO,CAAC,CAAC,CACP,CAAC;QACD,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,IAAI,KAAK,eAAe,CAC3B,CAAC;AACJ,CAAC;AATD,0CASC;AAED;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IAEtC,YAAY,OAAgB;QAC1B,OAAO,GAAG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