Suppressing exceptions is generally a bad idea and defeats the purpose of exception handling. Each type of exception provides an insight into what exactly went wrong and provides scenario-specific ways for graceful recovery. While it is easy to recover from some exceptions, a small subset of them make the recovery very difficult, usually because the conditions are not suitable for the program to continue executing. It is therefore suggested that you switch to a better approach of exception handling and recovery.
try {
// do something
} catch {
case ex: Exception => ...
}
try {
// do something
} catch {
case fooEx: FooException => ...
case barEx: BarException => ...
case _ => ...
}
A more idiomatic approach would be -
Try(/* do something */) match {
case Success(...) => ...
case Failure(e: FooException) => ...
case Failure(e: BarException) => ...
case Failure(e) => ...
}
Make sure to import Try, Success and Failure from scala.util.
https://docs.scala-lang.org/overviews/scala-book/functional-error-handling.html