/**
 * Base Error Class
 *
 * Foundation for all application-specific errors.
 */
export class CodeBuddyError extends Error {
    code;
    isOperational;
    timestamp;
    context;
    constructor(code, message, options = {}) {
        super(message);
        this.name = 'CodeBuddyError';
        this.code = code;
        this.isOperational = options.isOperational ?? true;
        this.timestamp = new Date();
        this.context = options.context;
        if (options.cause) {
            this.cause = options.cause;
        }
        // Capture stack trace
        Error.captureStackTrace(this, this.constructor);
    }
    toJSON() {
        return {
            name: this.name,
            code: this.code,
            message: this.message,
            timestamp: this.timestamp.toISOString(),
            context: this.context,
            stack: this.stack,
        };
    }
}
//# sourceMappingURL=base-error.js.map