-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
59 lines (46 loc) · 1.3 KB
/
index.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict';
class BadRequest extends Error {
constructor(message) {
// Call constructor for Error
super(message);
this.name = this.constructor.name;
this.message = message;
this.status = 400;
// Don't capture this function in the stack
Error.captureStackTrace(this, this.constructor);
}
}
class Unauthorized extends Error {
constructor(message) {
// Call constructor for Error
super(message);
this.name = this.constructor.name;
this.message = message;
this.status = 401;
// Don't capture this function in the stack
Error.captureStackTrace(this, this.constructor);
}
}
class Forbidden extends Error {
constructor(message) {
// Call constructor for Error
super(message);
this.name = this.constructor.name;
this.message = message;
this.status = 403;
// Don't capture this function in the stack
Error.captureStackTrace(this, this.constructor);
}
}
class NotFound extends Error {
constructor(message) {
// Call constructor for Error
super(message);
this.name = this.constructor.name;
this.message = message;
this.status = 404;
// Don't capture this function in the stack
Error.captureStackTrace(this, this.constructor);
}
}
module.exports = { BadRequest, Unauthorized, Forbidden, NotFound };