zcatalyst-cli
Version:
Command Line Tool for CATALYST
35 lines (34 loc) • 1.34 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("./util_modules/logger/index");
const index_js_1 = __importDefault(require("./error/index.js"));
const constants_1 = require("./util_modules/constants");
const context_help_js_1 = __importDefault(require("./error/context-help.js"));
const runtime_store_js_1 = __importDefault(require("./runtime-store.js"));
exports.default = (error, status) => {
if (typeof error === 'string') {
error = new index_js_1.default('An unexpected error has occurred.', {
status,
original: new Error(error),
exit: 2
});
}
if (error && error.name !== constants_1.DEFAULT.catalystError) {
error = new index_js_1.default('An unexpected error has occurred.', {
status,
original: error,
exit: 2
});
}
try {
const exitCode = (0, context_help_js_1.default)();
runtime_store_js_1.default.set('exitCode', typeof exitCode === 'number' ? exitCode : 2);
}
catch (err) {
(0, index_1.debug)('HELP ERROR: ' + err.stack);
runtime_store_js_1.default.set('exitCode', 2);
}
};