@nr1e/commons 0.0.2-alpha.10 → 0.0.2-alpha.12
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 +11 -8
- package/errors/errors.js +23 -15
- package/errors/errors.js.map +1 -1
- package/package.json +1 -1
package/errors/errors.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ interface IError {
|
|
|
4
4
|
name?: string;
|
|
5
5
|
statusCode?: HttpStatusCode | number;
|
|
6
6
|
}
|
|
7
|
+
export interface ErrorBody {
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
7
10
|
/**
|
|
8
11
|
* Checks if the given parameter is a NotFoundError.
|
|
9
12
|
*
|
|
@@ -15,7 +18,7 @@ export declare function isNotFoundError(e?: IError | null): e is NotFoundError;
|
|
|
15
18
|
*/
|
|
16
19
|
export declare class NotFoundError extends Error {
|
|
17
20
|
readonly statusCode = HttpStatusCode.NOT_FOUND;
|
|
18
|
-
readonly body:
|
|
21
|
+
readonly body: ErrorBody | undefined;
|
|
19
22
|
constructor(message?: string);
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
@@ -29,7 +32,7 @@ export declare function isForbiddenError(e?: IError | null): e is ForbiddenError
|
|
|
29
32
|
*/
|
|
30
33
|
export declare class ForbiddenError extends Error {
|
|
31
34
|
readonly statusCode = HttpStatusCode.FORBIDDEN;
|
|
32
|
-
readonly body:
|
|
35
|
+
readonly body: ErrorBody | undefined;
|
|
33
36
|
constructor(message?: string);
|
|
34
37
|
}
|
|
35
38
|
/**
|
|
@@ -43,7 +46,7 @@ export declare function isValidationError(e?: IError | null): e is ValidationErr
|
|
|
43
46
|
*/
|
|
44
47
|
export declare class ValidationError extends Error {
|
|
45
48
|
readonly statusCode = HttpStatusCode.BAD_REQUEST;
|
|
46
|
-
readonly body:
|
|
49
|
+
readonly body: ErrorBody | undefined;
|
|
47
50
|
constructor(message?: string);
|
|
48
51
|
}
|
|
49
52
|
/**
|
|
@@ -57,7 +60,7 @@ export declare function isBadRequestError(e?: IError | null): e is BadRequestErr
|
|
|
57
60
|
*/
|
|
58
61
|
export declare class BadRequestError extends Error {
|
|
59
62
|
readonly statusCode = HttpStatusCode.BAD_REQUEST;
|
|
60
|
-
readonly body:
|
|
63
|
+
readonly body: ErrorBody | undefined;
|
|
61
64
|
constructor(message?: string);
|
|
62
65
|
}
|
|
63
66
|
/**
|
|
@@ -71,7 +74,7 @@ export declare function isInternalServerError(e?: IError | null): e is InternalS
|
|
|
71
74
|
*/
|
|
72
75
|
export declare class InternalServerError extends Error {
|
|
73
76
|
readonly statusCode = HttpStatusCode.INTERNAL_SERVER_ERROR;
|
|
74
|
-
readonly body:
|
|
77
|
+
readonly body: ErrorBody | undefined;
|
|
75
78
|
constructor(message?: string);
|
|
76
79
|
}
|
|
77
80
|
/**
|
|
@@ -85,7 +88,7 @@ export declare function isConflictError(e?: IError | null): e is ConflictError;
|
|
|
85
88
|
*/
|
|
86
89
|
export declare class ConflictError extends Error {
|
|
87
90
|
readonly statusCode = HttpStatusCode.CONFLICT;
|
|
88
|
-
readonly body:
|
|
91
|
+
readonly body: ErrorBody | undefined;
|
|
89
92
|
constructor(message?: string);
|
|
90
93
|
}
|
|
91
94
|
/**
|
|
@@ -99,7 +102,7 @@ export declare function isUnsupportedMediaTypeError(e?: IError | null): e is Uns
|
|
|
99
102
|
*/
|
|
100
103
|
export declare class UnsupportedMediaTypeError extends Error {
|
|
101
104
|
readonly statusCode = HttpStatusCode.UNSUPPORTED_MEDIA_TYPE;
|
|
102
|
-
readonly body:
|
|
105
|
+
readonly body: ErrorBody | undefined;
|
|
103
106
|
constructor(message?: string);
|
|
104
107
|
}
|
|
105
108
|
/**
|
|
@@ -113,7 +116,7 @@ export declare function isNotImplementedError(e?: IError | null): e is NotImplem
|
|
|
113
116
|
*/
|
|
114
117
|
export declare class NotImplementedError extends Error {
|
|
115
118
|
readonly statusCode = HttpStatusCode.NOT_IMPLEMENTED;
|
|
116
|
-
readonly body:
|
|
119
|
+
readonly body: ErrorBody | undefined;
|
|
117
120
|
readonly expose = true;
|
|
118
121
|
constructor(message?: string);
|
|
119
122
|
}
|
package/errors/errors.js
CHANGED
|
@@ -20,9 +20,10 @@ exports.isNotFoundError = isNotFoundError;
|
|
|
20
20
|
*/
|
|
21
21
|
class NotFoundError extends Error {
|
|
22
22
|
constructor(message) {
|
|
23
|
-
|
|
23
|
+
message = message !== null && message !== void 0 ? message : 'Not found';
|
|
24
|
+
super(message);
|
|
24
25
|
this.statusCode = http_1.HttpStatusCode.NOT_FOUND;
|
|
25
|
-
this.body = message;
|
|
26
|
+
this.body = { message };
|
|
26
27
|
this.name = 'NotFoundError';
|
|
27
28
|
}
|
|
28
29
|
}
|
|
@@ -45,9 +46,10 @@ exports.isForbiddenError = isForbiddenError;
|
|
|
45
46
|
*/
|
|
46
47
|
class ForbiddenError extends Error {
|
|
47
48
|
constructor(message) {
|
|
48
|
-
|
|
49
|
+
message = message !== null && message !== void 0 ? message : 'Forbidden';
|
|
50
|
+
super(message);
|
|
49
51
|
this.statusCode = http_1.HttpStatusCode.FORBIDDEN;
|
|
50
|
-
this.body = message;
|
|
52
|
+
this.body = { message };
|
|
51
53
|
this.name = 'ForbiddenError';
|
|
52
54
|
}
|
|
53
55
|
}
|
|
@@ -66,9 +68,10 @@ exports.isValidationError = isValidationError;
|
|
|
66
68
|
*/
|
|
67
69
|
class ValidationError extends Error {
|
|
68
70
|
constructor(message) {
|
|
69
|
-
|
|
71
|
+
message = message !== null && message !== void 0 ? message : 'Validation error';
|
|
72
|
+
super(message);
|
|
70
73
|
this.statusCode = http_1.HttpStatusCode.BAD_REQUEST;
|
|
71
|
-
this.body = message;
|
|
74
|
+
this.body = { message };
|
|
72
75
|
this.name = 'ValidationError';
|
|
73
76
|
}
|
|
74
77
|
}
|
|
@@ -87,9 +90,10 @@ exports.isBadRequestError = isBadRequestError;
|
|
|
87
90
|
*/
|
|
88
91
|
class BadRequestError extends Error {
|
|
89
92
|
constructor(message) {
|
|
93
|
+
message = message !== null && message !== void 0 ? message : 'Bad request';
|
|
90
94
|
super(message !== null && message !== void 0 ? message : 'Bad request');
|
|
91
95
|
this.statusCode = http_1.HttpStatusCode.BAD_REQUEST;
|
|
92
|
-
this.body = message;
|
|
96
|
+
this.body = { message };
|
|
93
97
|
this.name = 'BadRequestError';
|
|
94
98
|
}
|
|
95
99
|
}
|
|
@@ -108,9 +112,10 @@ exports.isInternalServerError = isInternalServerError;
|
|
|
108
112
|
*/
|
|
109
113
|
class InternalServerError extends Error {
|
|
110
114
|
constructor(message) {
|
|
111
|
-
|
|
115
|
+
message = message !== null && message !== void 0 ? message : 'Internal server error';
|
|
116
|
+
super(message);
|
|
112
117
|
this.statusCode = http_1.HttpStatusCode.INTERNAL_SERVER_ERROR;
|
|
113
|
-
this.body = message;
|
|
118
|
+
this.body = { message };
|
|
114
119
|
this.name = 'InternalServerError';
|
|
115
120
|
}
|
|
116
121
|
}
|
|
@@ -129,9 +134,10 @@ exports.isConflictError = isConflictError;
|
|
|
129
134
|
*/
|
|
130
135
|
class ConflictError extends Error {
|
|
131
136
|
constructor(message) {
|
|
132
|
-
|
|
137
|
+
message = message !== null && message !== void 0 ? message : 'Conflict';
|
|
138
|
+
super(message);
|
|
133
139
|
this.statusCode = http_1.HttpStatusCode.CONFLICT;
|
|
134
|
-
this.body = message;
|
|
140
|
+
this.body = { message };
|
|
135
141
|
this.name = 'ConflictError';
|
|
136
142
|
}
|
|
137
143
|
}
|
|
@@ -153,9 +159,10 @@ exports.isUnsupportedMediaTypeError = isUnsupportedMediaTypeError;
|
|
|
153
159
|
*/
|
|
154
160
|
class UnsupportedMediaTypeError extends Error {
|
|
155
161
|
constructor(message) {
|
|
156
|
-
|
|
162
|
+
message = message !== null && message !== void 0 ? message : 'Unsupported media type';
|
|
163
|
+
super(message);
|
|
157
164
|
this.statusCode = http_1.HttpStatusCode.UNSUPPORTED_MEDIA_TYPE;
|
|
158
|
-
this.body = message;
|
|
165
|
+
this.body = { message };
|
|
159
166
|
this.name = 'UnsupportedMediaTypeError';
|
|
160
167
|
}
|
|
161
168
|
}
|
|
@@ -174,10 +181,11 @@ exports.isNotImplementedError = isNotImplementedError;
|
|
|
174
181
|
*/
|
|
175
182
|
class NotImplementedError extends Error {
|
|
176
183
|
constructor(message) {
|
|
177
|
-
|
|
184
|
+
message = message !== null && message !== void 0 ? message : 'Not implemented';
|
|
185
|
+
super(message);
|
|
178
186
|
this.statusCode = http_1.HttpStatusCode.NOT_IMPLEMENTED;
|
|
179
187
|
this.expose = true;
|
|
180
|
-
this.body = message;
|
|
188
|
+
this.body = { message };
|
|
181
189
|
this.name = 'NotImplementedError';
|
|
182
190
|
}
|
|
183
191
|
}
|
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;AAYvC;;;;GAIG;AACH,SAAgB,eAAe,CAAC,CAAiB;IAC/C,OAAO,CAAC,CAAC,CACP,CAAC;QACD,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,IAAI,KAAK,eAAe,CAC3B,CAAC;AACJ,CAAC;AARD,0CAQC;AAED;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IAGtC,YAAY,OAAgB;QAC1B,OAAO,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,WAAW,CAAC;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,eAAU,GAAG,qBAAc,CAAC,SAAS,CAAC;QAK7C,IAAI,CAAC,IAAI,GAAG,EAAC,OAAO,EAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AATD,sCASC;AAED;;;;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