chore:目录重构

This commit is contained in:
陈淳
2023-04-15 17:35:22 +08:00
parent a612af4f68
commit fb27fb8aa4
238 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
using System.Runtime.ExceptionServices;
using Microsoft.Extensions.Logging;
using Yi.Framework.Infrastructure.Enums;
namespace Yi.Framework.Infrastructure.Exceptions;
/// <summary>
/// <see cref="Exception"/><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9><EFBFBD><EFBFBD>
/// </summary>
public static class ExceptionExtensions
{
/// <summary>
/// ʹ<><CAB9> <see cref="ExceptionDispatchInfo.Capture"/> <20>ٴ<EFBFBD><D9B4>׳<EFBFBD><D7B3>
/// </summary>
/// <param name="exception">Exception to be re-thrown</param>
public static void ReThrow(this Exception exception)
{
ExceptionDispatchInfo.Capture(exception).Throw();
}
/// <summary>
/// <20><>ȡ<EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>־<EFBFBD>ȼ<EFBFBD>
/// </summary>
/// <param name="exception"></param>
/// <param name="defaultLevel"></param>
/// <returns></returns>
public static LogLevel GetLogLevel(this Exception exception, LogLevel defaultLevel = LogLevel.Error)
{
return (exception as IHasLogLevel)?.LogLevel ?? defaultLevel;
}
/// <summary>
/// <20><>ȡ<EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="exception"></param>
/// <param name="defaultLevel"></param>
/// <returns></returns>
public static int GetLogErrorCode(this Exception exception, ResultCodeEnum defaultCode = ResultCodeEnum.NotSuccess)
{
return (exception as IHasErrorCode)?.Code ?? (int)defaultCode;
}
}