I have a source file which has some bad data records, I want to handle `ArrayIndexOutofBoundsException` and increment my accumulator which is used to output bad data records.

```
val test = sourceFile.map(x => x.split("\\|")).
  filter(line => line(0).contains("1017")).map(x => {
    try {
      x.filter(line => {
        line.length >= 37
      }).map(x => x(38))
    }
    catch {
      case x: ArrayIndexOutOfBoundsException => {
        println("Bad Data Found".format(x))
        Linecounter += 1
        None
      }
    }
  })

test.count()
test.saveAsTextFile(Quotepath)
println("Bad Data Count %s:-".format(Linecounter))

```

Problem is I can't see accumulator output as count of records example 1 or etc .., can anyone help not sure whats wrong here.