in app/models/Attempt.scala [124:156]
def Right[A](a: A): Attempt[A] =
Attempt(Future.successful(scala.Right(a)))
/** Create an Attempt failure from an AMIableErrors instance, representing the
* possibility of multiple failures.
*/
def Left[A](errs: AMIableErrors): Attempt[A] =
Attempt(Future.successful(scala.Left(errs)))
/** Create an Attempt failure if there's only a single error.
*/
def Left[A](err: AMIableError): Attempt[A] =
Attempt(Future.successful(scala.Left(AMIableErrors(err))))
/** Asyncronous versions of the Attempt Right/Left helpers for when you have a
* Future that returns a good/bad value directly.
*/
object Async {
/** Create an Attempt from a Future of a good value.
*/
def Right[A](fa: Future[A])(implicit ec: ExecutionContext): Attempt[A] =
Attempt(fa.map(scala.Right(_)))
/** Create an Attempt from a known failure in the future. For example, if a
* piece of logic fails but you need to make a Database/API call to get the
* failure information.
*/
def Left[A](ferr: Future[AMIableErrors])(implicit
ec: ExecutionContext
): Attempt[A] =
Attempt(ferr.map(scala.Left(_)))
}