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