forked from SuprDewd/uva-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.js
40 lines (33 loc) · 1.11 KB
/
errors.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
const util = require('util');
var AbstractError = (function(){
function cls(msg, constr)
{
// If defined, pass the constr property to V8's
// captureStackTrace to clean up the output
Error.captureStackTrace(this, constr || this);
// If defined, store a custom error message
if (msg) this.message = msg;
}
util.inherits(cls, Error);
cls.prototype.name = 'Abstract Error';
return cls;
})();
function makeError(name, msg)
{
function cls(msg)
{
cls.super_.call(this, msg, this.constructor);
}
util.inherits(cls, AbstractError);
cls.prototype.name = name;
cls.prototype.message = msg;
return cls;
}
module.exports = {
IsCurrent: makeError('IsCurrent Error', 'Account is current'),
NotExist: makeError('NotExist Error', 'No such account'),
NoEditor: makeError('NoEditor Error', 'No editor configured'),
NoBrowser: makeError('NoBrowser Error', 'No browser configured'),
UnmatchedQuote: makeError('UnmatchedQuote Error', 'Unmatched quote'),
UnknownLang: makeError('UnknownLang Error', 'unknown language')
};