2016-08-27 03:29:57 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
class EnigError extends Error {
|
2018-06-22 05:15:04 +00:00
|
|
|
constructor(message, code, reason, reasonCode) {
|
|
|
|
super(message);
|
2016-08-27 03:29:57 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
this.name = this.constructor.name;
|
|
|
|
this.message = message;
|
|
|
|
this.code = code;
|
|
|
|
this.reason = reason;
|
2018-06-23 03:26:46 +00:00
|
|
|
this.reasonCode = reasonCode;
|
2016-08-27 03:29:57 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
if (this.reason) {
|
2018-06-22 05:15:04 +00:00
|
|
|
this.message += `: ${this.reason}`;
|
|
|
|
}
|
2018-01-20 22:16:10 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
if (typeof Error.captureStackTrace === 'function') {
|
2018-06-22 05:15:04 +00:00
|
|
|
Error.captureStackTrace(this, this.constructor);
|
|
|
|
} else {
|
2022-06-05 20:04:25 +00:00
|
|
|
this.stack = new Error(message).stack;
|
2018-06-22 05:15:04 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-27 03:29:57 +00:00
|
|
|
}
|
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
exports.EnigError = EnigError;
|
2016-09-20 03:30:26 +00:00
|
|
|
|
|
|
|
exports.Errors = {
|
2022-06-05 20:04:25 +00:00
|
|
|
General: (reason, reasonCode) =>
|
|
|
|
new EnigError('An error occurred', -33000, reason, reasonCode),
|
|
|
|
MenuStack: (reason, reasonCode) =>
|
|
|
|
new EnigError('Menu stack error', -33001, reason, reasonCode),
|
|
|
|
DoesNotExist: (reason, reasonCode) =>
|
|
|
|
new EnigError('Object does not exist', -33002, reason, reasonCode),
|
|
|
|
AccessDenied: (reason, reasonCode) =>
|
|
|
|
new EnigError('Access denied', -32003, reason, reasonCode),
|
|
|
|
Invalid: (reason, reasonCode) => new EnigError('Invalid', -32004, reason, reasonCode),
|
|
|
|
ExternalProcess: (reason, reasonCode) =>
|
|
|
|
new EnigError('External process error', -32005, reason, reasonCode),
|
|
|
|
MissingConfig: (reason, reasonCode) =>
|
|
|
|
new EnigError('Missing configuration', -32006, reason, reasonCode),
|
|
|
|
UnexpectedState: (reason, reasonCode) =>
|
|
|
|
new EnigError('Unexpected state', -32007, reason, reasonCode),
|
|
|
|
MissingParam: (reason, reasonCode) =>
|
2023-01-09 03:34:30 +00:00
|
|
|
new EnigError('Missing parameter(s)', -32008, reason, reasonCode),
|
2022-06-05 20:04:25 +00:00
|
|
|
MissingMci: (reason, reasonCode) =>
|
|
|
|
new EnigError('Missing required MCI code(s)', -32009, reason, reasonCode),
|
|
|
|
BadLogin: (reason, reasonCode) =>
|
|
|
|
new EnigError('Bad login attempt', -32010, reason, reasonCode),
|
|
|
|
UserInterrupt: (reason, reasonCode) =>
|
|
|
|
new EnigError('User interrupted', -32011, reason, reasonCode),
|
|
|
|
NothingToDo: (reason, reasonCode) =>
|
|
|
|
new EnigError('Nothing to do', -32012, reason, reasonCode),
|
2023-01-09 03:34:30 +00:00
|
|
|
HttpError: (reason, reasonCode) =>
|
|
|
|
new EnigError('HTTP error', -32013, reason, reasonCode),
|
|
|
|
Timeout: (reason, reasonCode) => new EnigError('Timeout', -32014, reason, reasonCode),
|
2023-01-12 05:37:09 +00:00
|
|
|
MissingProperty: (reason, reasonCode) =>
|
|
|
|
new EnigError('Missing property', -32014, reason, reasonCode),
|
2023-01-26 01:41:47 +00:00
|
|
|
Expired: (reason, reasonCode) => new EnigError('Expired', -32015, reason, reasonCode),
|
2023-02-01 05:16:19 +00:00
|
|
|
BadFormData: (reason, reasonCode) =>
|
|
|
|
new EnigError('Bad or missing form data', -32016, reason, reasonCode),
|
2023-02-03 22:14:27 +00:00
|
|
|
Duplicate: (reason, reasonCode) =>
|
|
|
|
new EnigError('Duplicate', -32017, reason, reasonCode),
|
2023-02-04 20:44:55 +00:00
|
|
|
ValidationFailed: (reason, reasonCode) =>
|
|
|
|
new EnigError('Validation failed', -32018, reason, reasonCode),
|
2016-09-20 03:30:26 +00:00
|
|
|
};
|
2017-01-28 19:33:06 +00:00
|
|
|
|
|
|
|
exports.ErrorReasons = {
|
2022-06-05 20:04:25 +00:00
|
|
|
AlreadyThere: 'ALREADYTHERE',
|
|
|
|
InvalidNextMenu: 'BADNEXT',
|
|
|
|
NoPreviousMenu: 'NOPREV',
|
|
|
|
NoConditionMatch: 'NOCONDMATCH',
|
|
|
|
NotEnabled: 'NOTENABLED',
|
|
|
|
AlreadyLoggedIn: 'ALREADYLOGGEDIN',
|
|
|
|
TooMany: 'TOOMANY',
|
|
|
|
Disabled: 'DISABLED',
|
|
|
|
Inactive: 'INACTIVE',
|
|
|
|
Locked: 'LOCKED',
|
|
|
|
NotAllowed: 'NOTALLOWED',
|
|
|
|
Invalid2FA: 'INVALID2FA',
|
2023-02-04 20:44:55 +00:00
|
|
|
|
|
|
|
ValueTooShort: 'VALUE_TOO_SHORT',
|
|
|
|
ValueTooLong: 'VALUE_TOO_LONG',
|
|
|
|
ValueInvalid: 'VALUE_INVALID',
|
|
|
|
|
|
|
|
NotAvailable: 'NOT_AVAILABLE',
|
|
|
|
DoesNotExist: 'EEXIST',
|
2018-11-23 06:07:37 +00:00
|
|
|
};
|