"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mccOutsideError = exports.mccError = exports.mccErrorCode = exports.MCC_ERROR = void 0;
exports.MCC_ERROR = "mccError";
var mccErrorCode;
(function (mccErrorCode) {
    mccErrorCode[mccErrorCode["InvalidParameter"] = 0] = "InvalidParameter";
    mccErrorCode[mccErrorCode["InvalidData"] = 1] = "InvalidData";
    mccErrorCode[mccErrorCode["InvalidBlock"] = 2] = "InvalidBlock";
    mccErrorCode[mccErrorCode["InvalidTransaction"] = 3] = "InvalidTransaction";
    mccErrorCode[mccErrorCode["InvalidResponse"] = 4] = "InvalidResponse";
    mccErrorCode[mccErrorCode["InvalidMethodCall"] = 5] = "InvalidMethodCall";
    mccErrorCode[mccErrorCode["NotImplemented"] = 6] = "NotImplemented";
    mccErrorCode[mccErrorCode["OutsideError"] = 7] = "OutsideError";
})(mccErrorCode = exports.mccErrorCode || (exports.mccErrorCode = {}));
class mccError extends Error {
    constructor(errorCode, innerError) {
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        super(mccErrorCode[errorCode]);
        this.name = exports.MCC_ERROR;
        this.errorCode = errorCode;
        this.innerError = innerError;
    }
    toString() {
        var _a;
        let errorText = `${this.name}:${this.message} (${mccErrorCode[this.errorCode]}=${this.errorCode})\n`;
        if (this.innerError) {
            errorText += `INNER ERROR: ${this.innerError.name}:${this.message}\n`;
        }
        if ((_a = this.innerError) === null || _a === void 0 ? void 0 : _a.stack) {
            errorText += `INNER STACK:\n${this.innerError.stack}`;
        }
        else if (this.stack) {
            errorText += `STACK\n${this.stack}`;
        }
        else {
            errorText += `LOCAL STACK:\n${new Error().stack}`;
        }
        return errorText;
    }
}
exports.mccError = mccError;
class mccOutsideError extends mccError {
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    constructor(innerError) {
        super(mccErrorCode.OutsideError, innerError);
    }
}
exports.mccOutsideError = mccOutsideError;
//# sourceMappingURL=errors.js.map