【发布时间】:2013-04-20 07:00:23
【问题描述】:
除非 try/catch 不起作用,我认为它应该起作用,否则我希望捕获以下异常。相反,它只是抛出 NPE。
try {
scala.io.Source.fromInputStream(null)
} catch {
case e:Throwable => println("oh cr*p!")
}
相比之下,下面的代码确实有效。
try {
1/0
} catch {
case e:Throwable => println("oh cr*p")
}
【问题讨论】:
标签: scala exception-handling try-catch