Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import scala.concurrent.ExecutionContext
  2. import scala.concurrent.Future
  3. import scala.concurrent.ExecutionContext.Implicits.global
  4. import scala.util.control.NonFatal
  5.  
  6. val future = Future.successful(())
  7.  
  8. future.flatMap(_ => Future.failed(new Exception("Test"))).recover{case e => println(e)}
  9. //println will work: java.lang.Exception: Test
  10. //res9: Future[Unit] = Future(Success(()))
  11.  
  12. future.flatMap(throw new Exception("Test")).recover{case e => println(e)}
  13. // no message will be printed.
  14. //java.lang.Exception: Test
  15. // ammonite.$sess.cmd8$.<init>(cmd8.sc:1)
  16. // ammonite.$sess.cmd8$.<clinit>(cmd8.sc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement