Skip to content

Instantly share code, notes, and snippets.

@dkomanov
Created May 22, 2020 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkomanov/f64b7f99a5cf80d70179611de4c69fbc to your computer and use it in GitHub Desktop.
Save dkomanov/f64b7f99a5cf80d70179611de4c69fbc to your computer and use it in GitHub Desktop.
[writing-async-app-in-scala-part-1] for-comprehensions 3
implicit class BooleanFutureExtensions(val future: Future[Boolean]) extends AnyVal {
def orFail(e: => Throwable): Future[Boolean] =
future.transform(t => if (t.isSuccess && !t.get) Failure(e) else t)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment