namespace WCS.WorkEngineering.Worlds.Logs
{
    /// <summary>
    ///  已知异常
    /// </summary>
    public class KnownException : Exception
    {
        /// <summary>
        ///  日志级别
        /// </summary>
        public LogLevelEnum Level { get; set; }

        /// <summary>
        ///  日志上传类型
        /// </summary>
        public LogUpLoadEnum logUpLoad { get; set; }

        /// <summary>
        ///  构造函数
        ///  自定义日志级别
        ///  上抛类型，按日志级别默认处理 Low:NotUpLoad Mid:UpLoadWMS High:UpLoadWMS
        /// </summary>
        /// <param name="message">消息</param>
        /// <param name="level">日志级别</param>
        public KnownException(string message, LogLevelEnum level) : base(message)
        {
            Level = level;
            switch (level)
            {
                case LogLevelEnum.Low:
                    logUpLoad = LogUpLoadEnum.NotUpLoad;
                    break;

                case LogLevelEnum.Mid:
                    logUpLoad = LogUpLoadEnum.UpLoadWMS;
                    break;

                case LogLevelEnum.High:
                    logUpLoad = LogUpLoadEnum.UpLoadWMS;
                    break;

                default:
                    break;
            }
        }

        /// <summary>
        ///  构造函数
        ///  自定义日志级别与上抛类型
        /// </summary>
        /// <param name="message">消息</param>
        /// <param name="level">日志级别</param>
        /// <param name="logUpLoad"></param>
        public KnownException(string message, LogLevelEnum level, LogUpLoadEnum logUpLoad) : base(message)
        {
            Level = level;
            this.logUpLoad = logUpLoad;
        }

        /// <summary>
        ///  重写ToString方法
        /// </summary>
        /// <returns>返回级别与消息内容组合结果</returns>
        public override string ToString()
        {
            return $"级别:{Level},消息:{Message}";
        }
    }
}
