@nr1e/commons 0.0.2-alpha.6 → 0.0.2-alpha.8
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 +39 -0
- package/errors/errors.js +73 -1
- package/errors/errors.js.map +1 -1
- package/package.json +1 -1
package/errors/errors.d.ts
CHANGED
|
@@ -70,4 +70,43 @@ export declare class InternalServerError extends Error {
|
|
|
70
70
|
readonly statusCode = HttpStatusCode.INTERNAL_SERVER_ERROR;
|
|
71
71
|
constructor(message?: string);
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Checks if the given parameter is a ConflictError.
|
|
75
|
+
*
|
|
76
|
+
* @param e the parameter to check
|
|
77
|
+
*/
|
|
78
|
+
export declare function isConflictError(e?: IError | null): e is ConflictError;
|
|
79
|
+
/**
|
|
80
|
+
* Thrown when a conflict occurs.
|
|
81
|
+
*/
|
|
82
|
+
export declare class ConflictError extends Error {
|
|
83
|
+
readonly statusCode = HttpStatusCode.CONFLICT;
|
|
84
|
+
constructor(message?: string);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Checks if the given parameter is a UnsupportedMediaTypeError.
|
|
88
|
+
*
|
|
89
|
+
* @param e the parameter to check
|
|
90
|
+
*/
|
|
91
|
+
export declare function isUnsupportedMediaTypeError(e?: IError | null): e is UnsupportedMediaTypeError;
|
|
92
|
+
/**
|
|
93
|
+
* Thrown when a unsupported media type is used.
|
|
94
|
+
*/
|
|
95
|
+
export declare class UnsupportedMediaTypeError extends Error {
|
|
96
|
+
readonly statusCode = HttpStatusCode.UNSUPPORTED_MEDIA_TYPE;
|
|
97
|
+
constructor(message?: string);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Checks if the given parameter is a NotImplementedError.
|
|
101
|
+
*
|
|
102
|
+
* @param e the parameter to check
|
|
103
|
+
*/
|
|
104
|
+
export declare function isNotImplementedError(e?: IError | null): e is NotImplementedError;
|
|
105
|
+
/**
|
|
106
|
+
* Thrown when a requested operation is not implemented.
|
|
107
|
+
*/
|
|
108
|
+
export declare class NotImplementedError extends Error {
|
|
109
|
+
readonly statusCode = HttpStatusCode.NOT_IMPLEMENTED;
|
|
110
|
+
constructor(message?: string);
|
|
111
|
+
}
|
|
73
112
|
export {};
|
package/errors/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InternalServerError = exports.isInternalServerError = exports.BadRequestError = exports.isBadRequestError = exports.ValidationError = exports.isValidationError = exports.ForbiddenError = exports.isForbiddenError = exports.NotFoundError = exports.isNotFoundError = void 0;
|
|
3
|
+
exports.NotImplementedError = exports.isNotImplementedError = exports.UnsupportedMediaTypeError = exports.isUnsupportedMediaTypeError = exports.ConflictError = exports.isConflictError = exports.InternalServerError = exports.isInternalServerError = exports.BadRequestError = exports.isBadRequestError = exports.ValidationError = exports.isValidationError = exports.ForbiddenError = exports.isForbiddenError = exports.NotFoundError = exports.isNotFoundError = void 0;
|
|
4
4
|
const http_1 = require("../http");
|
|
5
5
|
/**
|
|
6
6
|
* Checks if the given parameter is a NotFoundError.
|
|
@@ -124,4 +124,76 @@ class InternalServerError extends Error {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
exports.InternalServerError = InternalServerError;
|
|
127
|
+
/**
|
|
128
|
+
* Checks if the given parameter is a ConflictError.
|
|
129
|
+
*
|
|
130
|
+
* @param e the parameter to check
|
|
131
|
+
*/
|
|
132
|
+
function isConflictError(e) {
|
|
133
|
+
return !!(e &&
|
|
134
|
+
e.stack &&
|
|
135
|
+
e.message &&
|
|
136
|
+
e.statusCode &&
|
|
137
|
+
e.name === 'ConflictError');
|
|
138
|
+
}
|
|
139
|
+
exports.isConflictError = isConflictError;
|
|
140
|
+
/**
|
|
141
|
+
* Thrown when a conflict occurs.
|
|
142
|
+
*/
|
|
143
|
+
class ConflictError extends Error {
|
|
144
|
+
constructor(message) {
|
|
145
|
+
super(message !== null && message !== void 0 ? message : 'Conflict');
|
|
146
|
+
this.statusCode = http_1.HttpStatusCode.CONFLICT;
|
|
147
|
+
this.name = 'ConflictError';
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.ConflictError = ConflictError;
|
|
151
|
+
/**
|
|
152
|
+
* Checks if the given parameter is a UnsupportedMediaTypeError.
|
|
153
|
+
*
|
|
154
|
+
* @param e the parameter to check
|
|
155
|
+
*/
|
|
156
|
+
function isUnsupportedMediaTypeError(e) {
|
|
157
|
+
return !!(e &&
|
|
158
|
+
e.stack &&
|
|
159
|
+
e.message &&
|
|
160
|
+
e.statusCode &&
|
|
161
|
+
e.name === 'UnsupportedMediaTypeError');
|
|
162
|
+
}
|
|
163
|
+
exports.isUnsupportedMediaTypeError = isUnsupportedMediaTypeError;
|
|
164
|
+
/**
|
|
165
|
+
* Thrown when a unsupported media type is used.
|
|
166
|
+
*/
|
|
167
|
+
class UnsupportedMediaTypeError extends Error {
|
|
168
|
+
constructor(message) {
|
|
169
|
+
super(message !== null && message !== void 0 ? message : 'Unsupported media type');
|
|
170
|
+
this.statusCode = http_1.HttpStatusCode.UNSUPPORTED_MEDIA_TYPE;
|
|
171
|
+
this.name = 'UnsupportedMediaTypeError';
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
|
|
175
|
+
/**
|
|
176
|
+
* Checks if the given parameter is a NotImplementedError.
|
|
177
|
+
*
|
|
178
|
+
* @param e the parameter to check
|
|
179
|
+
*/
|
|
180
|
+
function isNotImplementedError(e) {
|
|
181
|
+
return !!(e &&
|
|
182
|
+
e.stack &&
|
|
183
|
+
e.message &&
|
|
184
|
+
e.statusCode &&
|
|
185
|
+
e.name === 'NotImplementedError');
|
|
186
|
+
}
|
|
187
|
+
exports.isNotImplementedError = isNotImplementedError;
|
|
188
|
+
/**
|
|
189
|
+
* Thrown when a requested operation is not implemented.
|
|
190
|
+
*/
|
|
191
|
+
class NotImplementedError extends Error {
|
|
192
|
+
constructor(message) {
|
|
193
|
+
super(message !== null && message !== void 0 ? message : 'Not implemented');
|
|
194
|
+
this.statusCode = http_1.HttpStatusCode.NOT_IMPLEMENTED;
|
|
195
|
+
this.name = 'NotImplementedError';
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
exports.NotImplementedError = NotImplementedError;
|
|
127
199
|
//# sourceMappingURL=errors.js.map
|
package/errors/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["errors.ts"],"names":[],"mappings":";;;AAAA,kCAAuC;AASvC;;;;GAIG;AACH,SAAgB,eAAe,CAAC,CAAiB;IAC/C,OAAO,CAAC,CAAC,CACP,CAAC;QACD,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,IAAI,KAAK,eAAe,CAC3B,CAAC;AACJ,CAAC;AATD,0CASC;AAED;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["errors.ts"],"names":[],"mappings":";;;AAAA,kCAAuC;AASvC;;;;GAIG;AACH,SAAgB,eAAe,CAAC,CAAiB;IAC/C,OAAO,CAAC,CAAC,CACP,CAAC;QACD,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,UAAU;QACZ,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,KAAK,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,WAAW,CAAC,CAAC;QAFvB,eAAU,GAAG,qBAAc,CAAC,SAAS,CA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