Scala : Error handling: catching NullPointerException