Work on EnigError and usage as experiment; This will go to many other areas of the code

This commit is contained in:
Bryan Ashby 2016-09-19 21:30:26 -06:00
parent 6a28b3ff35
commit 7da0abdc39
4 changed files with 25 additions and 9 deletions

View file

@ -2,11 +2,14 @@
'use strict';
class EnigError extends Error {
constructor(message) {
constructor(message, code, reason, reasonCode) {
super(message);
this.name = this.constructor.name;
this.message = message;
this.code = code;
this.reason = reason;
this.reasonCode = reasonCode;
if(typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, this.constructor);
@ -16,4 +19,12 @@ class EnigError extends Error {
}
}
exports.EnigError = EnigError;
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),
};