Skip to content

Instantly share code, notes, and snippets.

Last active May 31, 2020
What would you like to do?
[writing-async-app-in-scala-part-1] option 1
implicit class FutureOfOptionExtensions[T](val v: Future[Option[T]]) extends AnyVal {
def orFail(e: => Throwable): Future[T] =
v.flatMap(_.fold[Future[T]](Future.failed(e), Future.successful)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment