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 {
|
|
|
|
this.stack = (new Error(message)).stack;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-20 03:30:26 +00:00
|
|
|
class EnigMenuError extends EnigError { }
|
|
|
|
|
|
|
|
exports.EnigError = EnigError;
|
|
|
|
exports.EnigMenuError = EnigMenuError;
|
|
|
|
|
|
|
|
exports.Errors = {
|
|
|
|
General : (reason, reasonCode) => new EnigError('An error occurred', -33000, reason, reasonCode),
|
|
|
|
MenuStack : (reason, reasonCode) => new EnigMenuError('Menu stack error', -33001, reason, reasonCode),
|
|
|
|
};
|