Catch clauses that simply catch and rethrow exceptions are redundant and can be removed. Exceptions are usually thrown in situations when something goes wrong. The severity of these situations may vary depending on what your application is attempting to do. The catch
clause allows you to trap one or more exceptions and provides you a way to recover gracefully from these situations. Simply trapping an exception and immediately throwing it without logging or attempting any recovery does not make any sense. It is either recommended that you do more than simply rethrowing exceptions or remove the exception handling altogether.
try {
str.toInt
} catch {
case ex: NumberFormatException => throw ex
}
try {
str.toInt
} catch {
case ex: NumberFormatException => ex.printStackTrace()
}