Exception
Exceptions are available in Scala via a try-catch-finally syntax that uses pattern matching.
try {
studentsList.add("Lin", "Taipei")
} catch {
case e: NullException => log.error(e, "........")
0
} finally {
...
}
trys
are also expression-oriented
val result: Int = try {
studentsList.add("Lin", "Taipei")
} catch {
case e: NullException => log.error(e, "........")
0
} finally {
...
}