-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.js
More file actions
33 lines (27 loc) · 788 Bytes
/
errors.js
File metadata and controls
33 lines (27 loc) · 788 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
29
30
31
32
33
var http = require('http');
var errors = {
// @TODO: This is a hack, take it out when fixed in models/business-model.js
MultipleChoices : 300,
BadRequest : 400,
InvalidArgument : 400,
InvalidCredentials: 401,
ResourceNotFound : 404,
NotSupported : 405,
Forbidden : 403,
Conflict : 409,
Internal : 500,
BadGateway : 502,
ServiceUnavailable: 503
};
Object.keys(errors).forEach(function (name) {
var code = errors[name];
module.exports[name] = function (message) {
this.constructor.prototype.__proto__ = Error.prototype
Error.captureStackTrace(this, this.constructor);
this.name = name;
this.code = code;
this.message = message;
this.fields = {};
Error.call(message);
};
});