Esempio n. 1
0
 private static ActResult CatchExceptionAsync(Func <Task> action)
 {
     try
     {
         action.Invoke().GetAwaiter().GetResult();
         return(ActResult.Ok());
     }
     catch (Exception ex)
     {
         return(ActResult.ThrewException(ex));
     }
 }
Esempio n. 2
0
 private static ActResult CatchException(Action action)
 {
     try
     {
         action.Invoke();
         return(ActResult.Ok());
     }
     catch (Exception ex)
     {
         return(ActResult.ThrewException(ex));
     }
 }
Esempio n. 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));
        }
Esempio n. 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));
        }