"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreError = void 0;
class CoreError extends Error {
    constructor(message, { reason = 'internal', error, ...info } = {}) {
        super();
        this.name = this.constructor.name;
        this.message = message;
        this.reason = reason;
        this.info = info;
        this.originalError = error;
        if (error instanceof Error) {
            this.message = `${message}: ${error.message}`;
            this.stack = error.stack;
        }
    }
    toJSON() {
        return { message: this.message, stack: this.stack, reason: this.reason, info: this.info };
    }
}
exports.CoreError = CoreError;
