示例#1
0
文件: TryAction.cs 项目: dfgs/LogLib
 public void OrThrow(ExceptionFactoryDelegate ExceptionFactory)
 {
     try
     {
         action();
     }
     catch (Exception ex)
     {
         Logger.Log(ComponentID, ComponentName, MethodName, LogLevels.Error, ExceptionFormatter.Format(ex));
         throw ExceptionFactory(ex, ComponentID, ComponentName, MethodName);
     }
 }
示例#2
0
 public async Task <T> OrThrow(ExceptionFactoryDelegate ExceptionFactory)
 {
     try
     {
         return(await function);
     }
     catch (Exception ex)
     {
         Logger.Log(ComponentID, ComponentName, MethodName, LogLevels.Error, ExceptionFormatter.Format(ex));
         throw ExceptionFactory(ex, ComponentID, ComponentName, MethodName);
     }
 }
示例#3
0
文件: TryAction.cs 项目: dfgs/LogLib
 public void OrThrow <TException>(string Message)
     where TException : TryException
 {
     try
     {
         action();
     }
     catch (Exception ex)
     {
         Logger.Log(ComponentID, ComponentName, MethodName, LogLevels.Error, ExceptionFormatter.Format(ex));
         throw (TException)Activator.CreateInstance(typeof(TException), Message, ex, ComponentID, ComponentName, MethodName);
     }
 }
示例#4
0
文件: TryAction.cs 项目: dfgs/LogLib
 public bool OrWarn(string Message)
 {
     return(OrWarn((Ex) => $"{Message}: {ExceptionFormatter.Format(Ex)}"));
 }
示例#5
0
 public bool OrWarn(out T Result, string Message)
 {
     return(OrWarn(out Result, (Ex) => $"{Message}: {ExceptionFormatter.Format(Ex)}"));
 }
示例#6
0
 public async Task <bool> OrWarn(string Message)
 {
     return(await OrWarn((Ex) => $"{Message}: {ExceptionFormatter.Format(Ex)}"));
 }