SHARE
TWEET

Untitled

a guest Aug 17th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.   * Handle error throws in future, return default value on error
  3.   */
  4. def recover(): Unit = {
  5.   val f: Future[String] = downloadBlob("ftp://blobs/8671").recover {
  6.     case e =>
  7.       println(s"fail download, ${e.getMessage}")
  8.       "empty blob"
  9.   }
  10.   println(Await.result(f, 10.seconds))
  11. }
  12.  
  13. /*
  14.  * output
  15. fail download, invalid uri
  16. empty blob
  17. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top