I have the following Tuple - (t1, t2): (Try, Try)
I want to check if both failed, or if one of them failed, but avoid code duplication. Sort of:
(t1,t2) match { case (Success(v1),Success(v2)) => new MyClass(v1,v2) case (Failure(e),_) | (_,Failure(e)) => println(e.getMessage) }
Of course, the 2nd operator will not work, since I need to provide different extraction parameters. but then I have to check them out, since I don’t know what failed and actually contains Throwable. I would like Try to act like Future, so it will have Try.sequence (t1, t2).
Any idea how to make this work elegantly?
source share