Try/catch/finally Expressions
try {
// your scala code here
}
catch {
case foo: FooException => handleFooException(foo)
case bar: BarException => handleBarException(bar)
case _: Throwable => println("Got some other kind of Throwable exception")
} finally {
// your scala code here, such as closing a database connection
// or file handle
}
Try/catch/finally Expressions → are a → Control Structures.
Semantic portal