-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_error.js
More file actions
28 lines (24 loc) · 756 Bytes
/
app_error.js
File metadata and controls
28 lines (24 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//Custom AppError class
class AppError extends Error {
constructor(message, errorType, httpErrorCode, isOperational) {
super();
this.message = message;
this.errorType = errorType || AppError.ErrorTypes.InternalServerError;
this.httpErrorCode = httpErrorCode || AppError.HttpErrorCodes.InternalServerError;
this.isOperational = isOperational || true;
Error.captureStackTrace(this, AppError);
}
}
AppError.ErrorTypes = {
NotFound: "NotFound",
UnauthorizedAccess: "Unauthorized Access",
PermissionDenied: "Permission Denied",
InternalServerError: "Internal Server Error"
}
AppError.HttpErrorCodes = {
NotFound: 404,
UnauthorizedAccess: 401,
PermissionDenied: 403,
InternalServerError: 500
}
module.exports = AppError;