For instance, I have two Try
objects. I want to get error if one or another fails and process it in the same way:
val t1 = Try(throw new Exception("one"))
val t2 = Try(throw new Exception("two"))
(t1, t2) match {
case (Success(_), Success(_)) => println("It's ok")
case _ : Failure(e), _) | (_, Failure(e) => // Compile error here
println("Fail", e) // Doesn't matter from where e was come
}
Is it possible to make this code with the same e
in both failure options compile?