public static CodeRunResult RunCode <TCodeResult>(Func <TCodeResult> code) { try { var result = code(); return(CodeRunResult.SuccessResult(result)); } catch (Exception exc) { return(CodeRunResult.ErrorResult(exc)); } }
public static CodeRunResult RunCode(Action code) { try { code(); return(CodeRunResult.SuccessResult()); } catch (Exception exc) { return(CodeRunResult.ErrorResult(exc)); } }
public static CodeRunResult RunCode <TErrorResult>(Action code, Func <Exception, TErrorResult> onCodeError) { try { code(); return(CodeRunResult.SuccessResult()); } catch (Exception exc) { var errResult = onCodeError(exc); return(CodeRunResult.ErrorResult(exc, errResult)); } }