I know the question is not something new but my context is different.I have been trying best possible way to handle exceptions effectively.Below is my experimental code
val in = List("1", "2", "3", "abc")
val sc = prepareConfig();
val rdd = sc.parallelize(in)
val mapRDD = rdd.map { x => Try { x.toInt } }
val successRDD = mapRDD.filter { x => x.isSuccess }
val successRDD2 =
successRDD.map { x => Try { x.get * x.get } }.filter{ _.isSuccess }
.
. // some more Transformation operations based on the use case
.
successRDD10.collect()
Assume that I may need to have 10 transformations which leads to end result. Should I need to have Try{} for all my transformations ? Expectation is I may get error in any of the 10 transformations.So i'm trying to filter successful results and passing it to next stage. so is the above one is effective way of exception handling or any other alternative approach recommended ?