Skip to content

Instantly share code, notes, and snippets.

@eboto
Last active September 28, 2016 20:08
Show Gist options
  • Save eboto/7fdd63a3419d9a026334d8373ab44540 to your computer and use it in GitHub Desktop.
Save eboto/7fdd63a3419d9a026334d8373ab44540 to your computer and use it in GitHub Desktop.
// If you create a Future inside another Future, the inner one
// will not log exceptions thrown in its body to the console.
//
// Why not?
//
// Example:
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
val fut = Future {
Future {
println("This print will show in the logs...")
throw new RuntimeException("But this exception never appears in the logs!")
}
1
}
Future {
throw new RuntimeException("This non-nested throwaway Future _also_ doesn't appear")
}
fut.foreach { _ => throw new RuntimeException("This exception appears also, as expected.") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment