using Microsoft.Extensions.Logging;

namespace Yi.Framework.AiHub.Domain.AiChat;

public class ChatErrorException : Exception
{
    public string? Code { get; set; }

    public string? Details { get; set; }

    public LogLevel LogLevel { get; set; }

    public ChatErrorException(
        string? code = null,
        string? message = null,
        string? details = null,
        Exception? innerException = null,
        LogLevel logLevel = LogLevel.Warning)
        : base(message, innerException)
    {
        this.Code = code;
        this.Details = details;
        this.LogLevel = logLevel;
    }

    public ChatErrorException WithData(string name, object value)
    {
        this.Data[(object)name] = value;
        return this;
    }
}