/*-------------------------------------------------------------------------
 * 功能描述：MessageTipExtension
 * 作者：xulisong
 * 创建时间： 2018/12/19 14:01:42
 * 版本号：v1.0
 *  -------------------------------------------------------------------------*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using FWindSoft;
using FWindSoft.Wpf;

namespace Com.FirmLib.UI
{
    public class MessageTipEx
    {
        public static void Show(Window owner, Exception ex)
        {
            string result = ex.Message;

            #region 异常详细信息
            #if DEBUG
            StringBuilder builder = new StringBuilder();
            builder.Append(ex.Message);
            builder.Append(Environment.NewLine);
            builder.Append(ex.StackTrace.ToString());
            result = builder.ToString(); 
            #endif
            #endregion

            if (ex is HttpApiException httpEx)
            {
                result = httpEx.ToString();
            }

            MessageTip.Show(owner,result,"错误提示");
        }

        public static void Show(Exception ex)
        {
            Show(null, ex);
        }
    }
}
