public static Try <O> Map <T, O>(this Try <T> @try, Func <T, O> func) { if (func == null) { throw new ArgumentNullException(nameof(func)); } Try <O> f = () => @try.Run().Match(t => Exceptional <O> .Return(func(t)), exception => Exceptional <O> .Return(exception)); return(f); }
public static Exceptional <T> Run <T>(this Try <T> @try) { try { return(@try()); } catch (Exception e) { return(Exceptional <T> .Return(e)); } }
public static Try <T> AsTry <T>(this Func <T> func) { return(() => Exceptional <T> .Return(func())); }