Empty catch block seems to be invalid in Scala
try {
func()
} catch {
} // error: illegal start of simple expression
How I can catch all
Some exceptions really aren't meant to be caught. You can request it anyway:
try { f(x) }
catch { case _: Throwable => }
but that's maybe not so safe.
All the safe exceptions are matched by scala.util.control.NonFatal, so you can:
import scala.util.control.NonFatal
try { f(x) }
catch { case NonFatal(t) => }
for a slightly less risky but still very useful catch.
Or scala.util.Try can do it for you:
Try { f(x) }
and you can pattern match on the result if you want to know what happened. (Try doesn't work so well when you want a finally block, however.)