Created
May 22, 2020 22:52
-
-
Save dkomanov/4a510341fb2c22bfc63b2ca044757eb0 to your computer and use it in GitHub Desktop.
[writing-async-app-in-scala-part-1] recoverFilter
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 FutureExtensions[T](val future: Future[T]) extends AnyVal { | |
def recoverFilter(f: => T): Future[T] = | |
future.recover { | |
case _: NoSuchElementException | ControlException => f | |
} | |
def recoverFilterWith(f: => Future[T]): Future[T] = | |
future.recoverWith { | |
case _: NoSuchElementException | ControlException => f | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment