def fromEither[A]()

in hq/app/utils/attempt/Attempt.scala [156:173]


  def fromEither[A](e: Either[FailedAttempt, A]): Attempt[A] =
    Attempt(Future.successful(e))

  def fromOption[A](optA: Option[A], ifNone: FailedAttempt): Attempt[A] =
    fromEither(optA.toRight(ifNone))

  /**
    * Convert a plain `Future` value to an attempt by providing a recovery handler.
    */
  def fromFuture[A](future: Future[A])(recovery: PartialFunction[Throwable, FailedAttempt])(implicit ec: ExecutionContext): Attempt[A] = {
    Attempt {
      future
        .map(scala.Right(_))
        .recover { case t =>
          scala.Left(recovery(t))
        }
    }
  }