tryEither<T> function

Result<T> tryEither<T>(
  1. T block(
    1. BindEither bind
    )
)

Implementation

Result<T> tryEither<T>(T Function(BindEither bind) block) {
  A bind<A>(Result<A> either) => either.fold((e) => throw e, identity);

  try {
    return Either.right(block(bind));
  } on Exception catch (e) {
    return Either.left(e);
  }
}