-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
32 lines (26 loc) · 875 Bytes
/
server.js
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
29
30
31
32
'use strict';
const DEFAULT_MESSAGES = require('./constants/defaultMessages');
const HTTP_STATUS_CODES = require('./constants/httpStatusCodes');
class SERVER_ERROR extends Error {
constructor(status, message = DEFAULT_MESSAGES.SERVER_ERROR, ...args) {
super(message, ...args);
this.status = status || HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR;
}
}
class DB_ERROR extends SERVER_ERROR {
constructor(message = DEFAULT_MESSAGES.SERVER_ERROR, ...args) {
super(HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR, message, ...args);
Error.captureStackTrace(this, DB_ERROR);
}
}
class S3_ERROR extends SERVER_ERROR {
constructor(message = DEFAULT_MESSAGES.SERVER_ERROR, ...args) {
super(HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR, message, ...args);
Error.captureStackTrace(this, S3_ERROR);
}
}
module.exports = {
DB_ERROR,
S3_ERROR,
SERVER_ERROR
};