You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// 提取异常详情信息
|
|
/// </summary>
|
|
/// <param name="currException">异常类型</param>
|
|
/// <param name="errorTitle">标题</param>
|
|
/// <returns>返回异常详情</returns>
|
|
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;
|
|
}
|
|
}
|
|
}
|