Scala how to recover exception in a for future
<p>Here is my question!
When I use several future tasks in a for expression, I'm confused with the result of exception recover.</p>

<pre><code>object ForTest {    
  def ft1(n: Int): Future[Int] = Future(n*2)
  def ft2(n: Int): Future[Int] = Future(60/n)
  def main(args : Array[String]) : Unit = {
    val n = 0
    val res =
      for {
        a1 &lt;- ft1(n)
        a2 &lt;- ft2(n)
      } yield (a1,a2)    
    res.map{ x =&gt;
      println(s"x=$x")
    }.recover{
      case t: Throwable =&gt;
        println(s"exception ${t.getStackTrace}")
    }    
  }
}
</code></pre>

<p>Above is my code. Sometimes it print out the exception, sometimes not, I'm totally confused. Can anyone help me?</p>