tryFuture<T> static method

Future<Validation<T>> tryFuture<T>(
  1. Future<T> f()
)

Implementation

static Future<Validation<T>> tryFuture<T>(Future<T> Function() f)
       => f().then(Valid)
             .catchError((err) {
               if (err is Exception) {
                 return Invalid<T>([Fail.withException(err)]);
               }
               else if (err is Error)
               {
                 return Invalid<T>([Fail.withError(err)]);
               }

               return Invalid<T>([Fail.withError(Error())]);
             });