"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleError = exports.ServerlessError = exports.InitError = exports.ConfigGetError = exports.ConfigError = exports.ConfigDeleteError = exports.CommandError = void 0;
/** @format */
var common_1 = require("../utils/common");
var handler_set_config_1 = require("../utils/handler-set-config");
var s_core_1 = __importDefault(require("../utils/s-core"));
var _a = (0, s_core_1.default)(), colors = _a.colors, report = _a.report, getMAC = _a.getMAC;
var command_error_1 = require("./command-error");
Object.defineProperty(exports, "CommandError", { enumerable: true, get: function () { return command_error_1.CommandError; } });
var config_delete_error_1 = require("./config-delete-error");
Object.defineProperty(exports, "ConfigDeleteError", { enumerable: true, get: function () { return config_delete_error_1.ConfigDeleteError; } });
var config_error_1 = require("./config-error");
Object.defineProperty(exports, "ConfigError", { enumerable: true, get: function () { return config_error_1.ConfigError; } });
var config_get_error_1 = require("./config-get-error");
Object.defineProperty(exports, "ConfigGetError", { enumerable: true, get: function () { return config_get_error_1.ConfigGetError; } });
var init_error_1 = require("./init-error");
Object.defineProperty(exports, "InitError", { enumerable: true, get: function () { return init_error_1.InitError; } });
var serverless_error_1 = require("./serverless-error");
Object.defineProperty(exports, "ServerlessError", { enumerable: true, get: function () { return serverless_error_1.ServerlessError; } });
var pid = getMAC().replace(/:/g, '');
function underline(prefix, link) {
    return "" + colors.gray(prefix) + colors.gray.underline(link);
}
function handleError(error, prefix, exit) {
    if (prefix === void 0) { prefix = 'Message:'; }
    if (exit === void 0) { exit = true; }
    var traceId = "" + pid + Date.now();
    console.log((0, common_1.red)("\u2716 " + prefix + "\n"));
    var analysis = (0, handler_set_config_1.getConfig)('analysis');
    if (analysis !== 'disable') {
        console.log(colors.gray("TraceId:     " + traceId));
    }
    console.log(colors.gray("Environment: " + (0, common_1.getVersion)()));
    console.log(underline('Documents:   ', 'https://www.serverless-devs.com'));
    console.log(underline('Discussions: ', 'https://github.com/Serverless-Devs/Serverless-Devs/discussions'));
    console.log(underline('Issues:      ', 'https://github.com/Serverless-Devs/Serverless-Devs/issues\n'));
    console.log((0, common_1.bgRed)('ERROR:'));
    console.log(error);
    console.log('');
    if (analysis !== 'disable') {
        console.log(colors.gray("Please copy traceId: " + traceId + " and join Dingding group: 33947367 for consultation."));
    }
    console.log(colors.gray("Run again with the '--debug' option or 's -h' to get more logs."));
    report({
        type: 'jsError',
        content: error,
        traceId: traceId,
    }).then(function () { return exit && process.exit(-1); });
}
exports.handleError = handleError;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZXJyb3IvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsY0FBYztBQUNkLDBDQUF5RDtBQUN6RCxrRUFBd0Q7QUFDeEQsMkRBQXNDO0FBQ2hDLElBQUEsS0FBNkIsSUFBQSxnQkFBTyxHQUFFLEVBQXBDLE1BQU0sWUFBQSxFQUFFLE1BQU0sWUFBQSxFQUFFLE1BQU0sWUFBYyxDQUFDO0FBQzdDLGlEQUErQztBQUF0Qyw2R0FBQSxZQUFZLE9BQUE7QUFDckIsNkRBQTBEO0FBQWpELHdIQUFBLGlCQUFpQixPQUFBO0FBQzFCLCtDQUE2QztBQUFwQywyR0FBQSxXQUFXLE9BQUE7QUFDcEIsdURBQW9EO0FBQTNDLGtIQUFBLGNBQWMsT0FBQTtBQUN2QiwyQ0FBeUM7QUFBaEMsdUdBQUEsU0FBUyxPQUFBO0FBQ2xCLHVEQUFxRDtBQUE1QyxtSEFBQSxlQUFlLE9BQUE7QUFFeEIsSUFBTSxHQUFHLEdBQUcsTUFBTSxFQUFFLENBQUMsT0FBTyxDQUFDLElBQUksRUFBRSxFQUFFLENBQUMsQ0FBQztBQUV2QyxTQUFTLFNBQVMsQ0FBQyxNQUFjLEVBQUUsSU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