using System;
using System.Collections.Generic;
using Abp.Json;

namespace YGNT.Infrastructure
{
    public static class MyExtend
    {
        /// <summary>
        /// 获取到最内部的错误信息
        /// </summary>
        /// <param name="exception"></param>
        /// <returns></returns>
        public static string GetInnerExceptionMessage(this Exception exception)
        {
            List<string> list = new List<string>();
            if (exception.Message != "发生一个或多个错误。")
                list.Add(exception.Message);
            while (exception.InnerException != null)
            {
                exception = exception.InnerException;
                list.Add(exception.Message);
            }
            return list.ToJsonString();
        }
    }
}