using Furion.FriendlyException; using MySqlX.XDevAPI.Common; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace Myshipping.Application { public static class ExceptionExtensionHelper { /// /// 提取异常详情信息 /// /// 异常类型 /// 标题 /// 返回异常详情 public static string GetMessage(this Exception currException, string errorTitle = "") { string msg = string.Empty; try { if (currException is InvalidOperationException) { msg = currException.Message; } else if(!string.IsNullOrWhiteSpace(errorTitle)) { msg = $"{errorTitle},原因:{currException.Message}"; } else { msg = currException.Message; } } catch (Exception ex) { throw Oops.Bah("提取异常详情失败", ex.Message); } return msg; } } }