mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 12:47:13 +02:00
Work on EnigError and usage as experiment; This will go to many other areas of the code
This commit is contained in:
parent
6a28b3ff35
commit
7da0abdc39
4 changed files with 25 additions and 9 deletions
|
@ -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),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue