2016-08-27 03:29:57 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
class EnigError extends Error {
|
2016-09-20 03:30:26 +00:00
|
|
|
constructor(message, code, reason, reasonCode) {
|
2016-08-27 03:29:57 +00:00
|
|
|
super(message);
|
|
|
|
|
|
|
|
this.name = this.constructor.name;
|
|
|
|
this.message = message;
|
2016-09-20 03:30:26 +00:00
|
|
|
this.code = code;
|
|
|
|
this.reason = reason;
|
|
|
|
this.reasonCode = reasonCode;
|
2016-08-27 03:29:57 +00:00
|
|
|
|
|
|
|
if(typeof Error.captureStackTrace === 'function') {
|
|
|
|
Error.captureStackTrace(this, this.constructor);
|
|
|
|
} else {
|
2018-01-15 19:22:11 +00:00
|
|
|
this.stack = (new Error(message)).stack;
|
2016-08-27 03:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-20 03:30:26 +00:00
|
|
|
exports.EnigError = EnigError;
|
|
|
|
|
|
|
|
exports.Errors = {
|
|
|
|
General : (reason, reasonCode) => new EnigError('An error occurred', -33000, reason, reasonCode),
|
2016-10-01 19:25:32 +00:00
|
|
|
MenuStack : (reason, reasonCode) => new EnigError('Menu stack error', -33001, reason, reasonCode),
|
2016-09-29 03:54:25 +00:00
|
|
|
DoesNotExist : (reason, reasonCode) => new EnigError('Object does not exist', -33002, reason, reasonCode),
|
2016-10-01 19:25:32 +00:00
|
|
|
AccessDenied : (reason, reasonCode) => new EnigError('Access denied', -32003, reason, reasonCode),
|
|
|
|
Invalid : (reason, reasonCode) => new EnigError('Invalid', -32004, reason, reasonCode),
|
2017-01-12 05:51:00 +00:00
|
|
|
ExternalProcess : (reason, reasonCode) => new EnigError('External process error', -32005, reason, reasonCode),
|
2017-01-26 05:18:05 +00:00
|
|
|
MissingConfig : (reason, reasonCode) => new EnigError('Missing configuration', -32006, reason, reasonCode),
|
2017-02-01 06:10:17 +00:00
|
|
|
UnexpectedState : (reason, reasonCode) => new EnigError('Unexpected state', -32007, reason, reasonCode),
|
2017-02-27 04:28:05 +00:00
|
|
|
MissingParam : (reason, reasonCode) => new EnigError('Missing paramater(s)', -32008, reason, reasonCode),
|
2016-09-20 03:30:26 +00:00
|
|
|
};
|
2017-01-28 19:33:06 +00:00
|
|
|
|
|
|
|
exports.ErrorReasons = {
|
|
|
|
AlreadyThere : 'ALREADYTHERE',
|
|
|
|
InvalidNextMenu : 'BADNEXT',
|
|
|
|
NoPreviousMenu : 'NOPREV',
|
|
|
|
NoConditionMatch : 'NOCONDMATCH',
|
2017-02-18 16:56:23 +00:00
|
|
|
NotEnabled : 'NOTENABLED',
|
2017-01-28 19:33:06 +00:00
|
|
|
};
|