#nullable enable
using System;

namespace IGP.UnitySDK
{
    public class IGPSDKException : Exception
    {
        public string? ErrorCode { get; }

        /// <summary>
        /// 错误分类，对齐 GameMaker bridge：validation / authorization / channel / runtime。
        /// 用于让游戏侧按语义决定是否重试、是否上提 UI。
        /// </summary>
        public string? Category { get; }

        /// <summary>
        /// desktop session 通道状态快照：disconnected / connecting / reachable / failed。
        /// 仅当错误由 desktop session 产生时有值。
        /// </summary>
        public string? DesktopChannelState { get; }

        /// <summary>
        /// desktop session attach 校验状态快照：idle / attaching / attached / rejected。
        /// 仅当错误由 desktop session 产生时有值。
        /// </summary>
        public string? DesktopAttachState { get; }

        public IGPSDKException(string message) : base(message) { }

        public IGPSDKException(string message, string errorCode) : base(message)
        {
            ErrorCode = errorCode;
        }

        public IGPSDKException(string message, Exception innerException) : base(message, innerException) { }

        public IGPSDKException(string message, string errorCode, Exception innerException)
            : base(message, innerException)
        {
            ErrorCode = errorCode;
        }

        public IGPSDKException(
            string message,
            string? errorCode,
            string? category,
            string? desktopChannelState,
            string? desktopAttachState)
            : base(message)
        {
            ErrorCode = errorCode;
            Category = category;
            DesktopChannelState = desktopChannelState;
            DesktopAttachState = desktopAttachState;
        }
    }
}
