Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. /**
  2. * Execute another future operation on failure
  3. */
  4. def recoverWith(): Unit = {
  5. val f: Future[String] = downloadBlob("ftp://blobs/8671").recoverWith {
  6. case e =>
  7. println(s"fail download, ${e.getMessage}")
  8. Future {
  9. "empty blob"
  10. }
  11. }
  12. println(Await.result(f, 10.seconds))
  13. }
  14.  
  15. /*
  16. * output
  17. fail download, invalid uri
  18. empty blob
  19. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement