using System.Diagnostics;

namespace Hotline.Logger.Models
{
    /// <summary>
    /// 异常日志
    /// </summary>
    public class ExceptionModel : BaseLogModel
    {
        /// <summary>
        /// 进程ID
        /// 应用程序的进程ID，可为空
        /// </summary>
        public string ProcessId
        {
            get
            {
                try
                {
                    return Process.GetCurrentProcess().Id.ToString();
                }
                catch
                {
                    return "获取进程Id失败";
                }
            }
        }

        /// <summary>
        /// 线程ID
        /// 可为空
        /// </summary>
        public string ThreadId
        {
            get
            {
                try
                {
                    return Thread.CurrentThread.ManagedThreadId.ToString();
                }
                catch
                {
                    return "获取线程Id失败";
                }
            }
        }

        /// <summary>
        /// 错误码
        /// 程序自定义的错误码，某种错误指定的错误码，没有定义时为为空
        /// </summary>
        public string ErrorCode { get; set; } = string.Empty;

        /// <summary>
        /// 异常信息
        /// Exception message信息
        /// </summary>
        public string Message { get; set; } = string.Empty;

        /// <summary>
        /// 异常上下文
        /// 包括了异常堆栈信息，用于分析具体问题
        /// </summary>
        public string Context { get; set; } = string.Empty;

        /// <summary>
        /// 被调用方法
        /// 被调用的方法，直接API地址
        /// </summary>
        public string Method { get; set; }
    }
}
