示例#1
0
 private static ActResult CatchExceptionAsync(Func <Task> action)
 {
     try
     {
         action.Invoke().GetAwaiter().GetResult();
         return(ActResult.Ok());
     }
     catch (Exception ex)
     {
         return(ActResult.ThrewException(ex));
     }
 }
示例#2
0
 private static ActResult CatchException(Action action)
 {
     try
     {
         action.Invoke();
         return(ActResult.Ok());
     }
     catch (Exception ex)
     {
         return(ActResult.ThrewException(ex));
     }
 }
示例#3
0
        private static ActResult <T> CatchExceptionAsync <T>(Func <Task <T> > func)
        {
            T result;

            try
            {
                result = func.Invoke().GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                return(ActResult.ThrewException <T>(ex));
            }

            return(ActResult.Ok(result));
        }
示例#4
0
        private static ActResult <T> CatchException <T>(Func <T> func)
        {
            T result;

            try
            {
                result = func.Invoke();
            }
            catch (Exception ex)
            {
                return(ActResult.ThrewException <T>(ex));
            }

            return(ActResult.Ok(result));
        }