Scala: Silently catch all exceptions

后端 未结 8 1520
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-31 05:34

Empty catch block seems to be invalid in Scala

try {
  func()
} catch {

} // error: illegal start of simple expression

How I can catch all

8条回答
  •  借酒劲吻你
    2020-12-31 05:56

    Just for a sake of completeness, there is a set of built-in methods in Exception, including silently catching exceptions. See Using scala.util.control.Exception for details on usage.

提交回复
热议问题