"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get CliError () {
        return CliError;
    },
    get handleExceptions () {
        return handleExceptions;
    }
});
function _chalk() {
    const data = /*#__PURE__*/ _interop_require_default(require("chalk"));
    _chalk = function() {
        return data;
    };
    return data;
}
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
class CliError extends Error {
    constructor(message){
        super(message);
        this.name = "CliError";
    }
}
const handleException = (e)=>{
    if (e instanceof Error && e.name === "ExitPromptError") {
        return;
    }
    if (e instanceof CliError) {
        console.log(_chalk().default.redBright(e.message));
        process.exit(1);
    }
    throw e;
};
const handleExceptions = ()=>{
    process.on("unhandledRejection", (reason, promise)=>{
        handleException(reason);
    });
    process.on("uncaughtException", (reason)=>{
        handleException(reason);
    });
};
