I am new to scala and have a requirement where i have to continue processing the next records when an exception arises.
object test {
def main(args: Array[String]) {
try {
val txt = Array("ABC", "DEF", "GHI")
val arr_val = txt(3)
println(arr_val)
val arr_val1 = txt(0)
println(arr_val1)
scala.util.control.Exception.ignoring(classOf[ArrayIndexOutOfBoundsException]) {
println { "Index ouf of Bounds" }
}
} catch {
case ex: NullPointerException =>
}
}
}
I tried ignoring the exception , but the value of arr_val1 is not getting printed because of the ArrayIndexOutOfBoundsException which arises ahead of this line.
Any help would be highly appreciated