public static void ThrowIfNotError <TValue>(ResultEx <TValue> result) { if (!result.IsError) { throw ResultHasNoErrorException.From(result); } }
public static ResultEx <TResult> Try <TResult>(Func <TResult> func) { try { return(ResultEx <TResult> .FromValue(func())); } catch (Exception e) { return(ResultEx <TResult> .FromError(e)); } }
public static ResultEx <TResult> Try <TResult, TArg>(Func <TArg, TResult> func, TArg arg) { try { return(ResultEx <TResult> .FromValue(func(arg))); } catch (Exception e) { return(ResultEx <TResult> .FromError(e)); } }
public static ResultEx <TValue> FromValue <TValue>(TValue value) { return(ResultEx <TValue> .FromValue(value)); }