Last active
May 31, 2020 11:38
-
-
Save dkomanov/1271d7f13aad9dc9142fcb2eaff173e5 to your computer and use it in GitHub Desktop.
[writing-async-app-in-scala-part-1] option 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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