using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace CloudBuilder.Core.Service
{
    public class ServiceErrorException : Exception
    {
        public string SourceCode { get; set; } = "CloudBuilder.Core.ServiceErrorException";

        public new string Message { get; set; } = string.Empty;

        /// <summary>
        /// 初始化<see cref="CloudBuilder.CoreException"/>类的新实例
        /// </summary>
        public ServiceErrorException()
        { }

        public ServiceErrorException(Exception ex)
      : base(ex.Message, ex)
        {
            Message = ex.Message;
        }

        /// <summary>
        /// 使用指定错误消息初始化<see cref="CloudBuilder.CoreException"/>类的新实例。
        /// </summary>
        /// <param name="message">描述错误的消息</param>
        public ServiceErrorException(string message)
            : base(message)
        {
            Message = message;
        }

        /// <summary>
        /// 使用异常消息与一个内部异常实例化一个<see cref="CloudBuilder.CoreException"/>类的新实例
        /// </summary>
        /// <param name="message">异常消息</param>
        /// <param name="inner">用于封装在<see cref="CloudBuilder.CoreException"/>内部的异常实例</param>
        public ServiceErrorException(string message, Exception inner)
            : base(message, inner)
        { Message = message; }

        /// <summary>
        /// 使用可序列化数据实例化一个<see cref="CloudBuilder.CoreException"/>类的新实例
        /// </summary>
        /// <param name="info">保存序列化对象数据的对象。</param>
        /// <param name="context">有关源或目标的上下文信息。</param>
        protected ServiceErrorException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        { }
    }
}
