forked from lisong/code-push-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app-error.js
35 lines (30 loc) · 841 Bytes
/
app-error.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
var util = require('util')
var AppError = function (msg, constr) {
if(msg) {
msg = msg.toString();
}
Error.captureStackTrace(this, constr || this)
this.message = msg || 'Error'
this.name = 'AppError'
this.status = 200
}
util.inherits(AppError, Error)
var NotFoundError = function(msg) {
NotFoundError.super_.call(this, msg, this.constructor)
this.message = msg || 'Not Found';
this.name = 'NotFoundError'
this.status = 404
}
util.inherits(NotFoundError, AppError)
var UnauthorizedError = function(msg) {
UnauthorizedError.super_.call(this, msg, this.constructor)
this.message = msg || `401 Unauthorized`;
this.name = 'UnauthorizedError'
this.status = 401
}
util.inherits(UnauthorizedError, AppError)
module.exports = {
AppError: AppError,
NotFound: NotFoundError,
Unauthorized: UnauthorizedError
}