@nr1e/commons 0.0.2-alpha.13 → 0.0.2-alpha.14
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 +0 -8
- 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
|
@@ -38,7 +38,6 @@ class NotFoundError extends Error {
|
|
|
38
38
|
message = message !== null && message !== void 0 ? message : 'Not found';
|
|
39
39
|
super(message);
|
|
40
40
|
this.statusCode = http_1.HttpStatusCode.NOT_FOUND;
|
|
41
|
-
this.body = { message };
|
|
42
41
|
this.name = 'NotFoundError';
|
|
43
42
|
}
|
|
44
43
|
}
|
|
@@ -65,7 +64,6 @@ class ForbiddenError extends Error {
|
|
|
65
64
|
message = message !== null && message !== void 0 ? message : 'Forbidden';
|
|
66
65
|
super(message);
|
|
67
66
|
this.statusCode = http_1.HttpStatusCode.FORBIDDEN;
|
|
68
|
-
this.body = { message };
|
|
69
67
|
this.name = 'ForbiddenError';
|
|
70
68
|
}
|
|
71
69
|
}
|
|
@@ -91,7 +89,6 @@ class ValidationError extends Error {
|
|
|
91
89
|
message = message !== null && message !== void 0 ? message : 'Validation error';
|
|
92
90
|
super(message);
|
|
93
91
|
this.statusCode = http_1.HttpStatusCode.BAD_REQUEST;
|
|
94
|
-
this.body = { message };
|
|
95
92
|
this.name = 'ValidationError';
|
|
96
93
|
}
|
|
97
94
|
}
|
|
@@ -117,7 +114,6 @@ class BadRequestError extends Error {
|
|
|
117
114
|
message = message !== null && message !== void 0 ? message : 'Bad request';
|
|
118
115
|
super(message !== null && message !== void 0 ? message : 'Bad request');
|
|
119
116
|
this.statusCode = http_1.HttpStatusCode.BAD_REQUEST;
|
|
120
|
-
this.body = { message };
|
|
121
117
|
this.name = 'BadRequestError';
|
|
122
118
|
}
|
|
123
119
|
}
|
|
@@ -143,7 +139,6 @@ class InternalServerError extends Error {
|
|
|
143
139
|
message = message !== null && message !== void 0 ? message : 'Internal server error';
|
|
144
140
|
super(message);
|
|
145
141
|
this.statusCode = http_1.HttpStatusCode.INTERNAL_SERVER_ERROR;
|
|
146
|
-
this.body = { message };
|
|
147
142
|
this.name = 'InternalServerError';
|
|
148
143
|
}
|
|
149
144
|
}
|
|
@@ -169,7 +164,6 @@ class ConflictError extends Error {
|
|
|
169
164
|
message = message !== null && message !== void 0 ? message : 'Conflict';
|
|
170
165
|
super(message);
|
|
171
166
|
this.statusCode = http_1.HttpStatusCode.CONFLICT;
|
|
172
|
-
this.body = { message };
|
|
173
167
|
this.name = 'ConflictError';
|
|
174
168
|
}
|
|
175
169
|
}
|
|
@@ -195,7 +189,6 @@ class UnsupportedMediaTypeError extends Error {
|
|
|
195
189
|
message = message !== null && message !== void 0 ? message : 'Unsupported media type';
|
|
196
190
|
super(message);
|
|
197
191
|
this.statusCode = http_1.HttpStatusCode.UNSUPPORTED_MEDIA_TYPE;
|
|
198
|
-
this.body = { message };
|
|
199
192
|
this.name = 'UnsupportedMediaTypeError';
|
|
200
193
|
}
|
|
201
194
|
}
|
|
@@ -222,7 +215,6 @@ class NotImplementedError extends Error {
|
|
|
222
215
|
super(message);
|
|
223
216
|
this.statusCode = http_1.HttpStatusCode.NOT_IMPLEMENTED;
|
|
224
217
|
this.expose = true;
|
|
225
|
-
this.body = { message };
|
|
226
218
|
this.name = 'NotImplementedError';
|
|
227
219
|
}
|
|
228
220
|
}
|
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,CACP,CAAC;QACD,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,IAAI,KAAK,WAAW,CACvB,CAAC;AACJ,CAAC;AATD,kCASC;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,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,WAAW,CAAC;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,eAAU,GAAG,qBAAc,CAAC,SAAS,CAAC;QAI7C,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAPD,sCAOC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,CAAiB;IAChD,OAAO,CAAC,CAAC,CACP,CAAC;QACD,CAAC,CAAC,KAAK;QACP,C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