@frontembed/test 1.0.0
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/helpers/errorHelpers.js +22 -0
- package/index.js +1 -0
- package/package.json +4 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class AppError extends Error {
|
|
2
|
+
constructor(message, statusCode) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.statusCode = statusCode;
|
|
5
|
+
this.isOperational = true;
|
|
6
|
+
Error.captureStackTrace(this, this.constructor);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function notFound(msg = 'Resource not found') {
|
|
11
|
+
return new AppError(msg, 404);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function badRequest(msg = 'Bad request') {
|
|
15
|
+
return new AppError(msg, 400);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function unauthorized(msg = 'Unauthorized') {
|
|
19
|
+
return new AppError(msg, 401);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = { AppError, notFound, badRequest, unauthorized };
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {};
|
package/package.json
ADDED