Beispiel #1
0
 public static void ThrowIfNotError <TValue>(ResultEx <TValue> result)
 {
     if (!result.IsError)
     {
         throw ResultHasNoErrorException.From(result);
     }
 }
Beispiel #2
0
 public static ResultEx <TResult> Try <TResult>(Func <TResult> func)
 {
     try
     {
         return(ResultEx <TResult> .FromValue(func()));
     }
     catch (Exception e)
     {
         return(ResultEx <TResult> .FromError(e));
     }
 }
Beispiel #3
0
 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));
     }
 }
Beispiel #4
0
 public static ResultEx <TValue> FromValue <TValue>(TValue value)
 {
     return(ResultEx <TValue> .FromValue(value));
 }