using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
namespace Utility
{
    public class AppFriendlyException : Exception
    {
        /// 
        /// 构造函数
        /// 
        public AppFriendlyException() : base()
        {
        }
        /// 
        /// 构造函数
        /// 
        /// 
        /// 
        public AppFriendlyException(string message, object errorCode) : base(message)
        {
            ErrorMessage = message;
            ErrorCode = OriginErrorCode = errorCode;
        }
        /// 
        /// 构造函数
        /// 
        /// 
        /// 
        /// 
        public AppFriendlyException(string message, object errorCode, Exception innerException) : base(message, innerException)
        {
            ErrorMessage = message;
            ErrorCode = OriginErrorCode = errorCode;
        }
        /// 
        /// 构造函数
        /// 
        /// 
        /// 
        public AppFriendlyException(SerializationInfo info, StreamingContext context) : base(info, context)
        {
        }
        /// 
        /// 错误码
        /// 
        public object ErrorCode { get; set; }
        /// 
        /// 错误码(没被复写过的 ErrorCode )
        /// 
        public object OriginErrorCode { get; set; }
        /// 
        /// 错误消息(支持 Object 对象)
        /// 
        public object ErrorMessage { get; set; }
        /// 
        /// 状态码
        /// 
        public int StatusCode { get; set; } = StatusCodes.Status500InternalServerError;
        /// 
        /// 是否是数据验证异常
        /// 
        public bool ValidationException { get; set; } = false;
        /// 
        /// 额外数据
        /// 
        public new object Data { get; set; }
    }
}