新增异常扩展

This commit is contained in:
FalconFly 2024-06-03 11:25:11 +08:00
parent e68ee4ec04
commit ecb879b571

View File

@ -0,0 +1,25 @@
using System;
namespace Falcon.SugarApi
{
/// <summary>
/// 异常扩展
/// </summary>
public static class ExceptionExtend
{
/// <summary>
/// 链接异常信息,返回异常信息长串。
/// </summary>
/// <param name="exception">异常信息</param>
/// <returns>异常信息长串</returns>
public static string InnerExceptionLink(this Exception exception) {
var inne = exception.InnerException;
if(inne == null) {
return exception.Message;
}
else {
return $"{exception.Message} ---> {inne.InnerExceptionLink()}";
}
}
}
}