try-Catch

1
2
3
4
5
6
7
8
try {
// ...
} catch {
case ex: Exception => {
ex.printStackTrace() // 打印到标准err
System.err.println("exception===>: ...") // 打印到标准err
}
}
1
2
3
4
5
6
7
try {
val a = 1 / 0
} catch {
case ex: Exception => {
println("bug")
}
}