All exceptions such as IllegalArgumentException
are sub types of RuntimeException
. Trapping a specific exception and then throwing a generalized Exception
is considered a bad practice and should be avoided. If the existing exceptions are not relevant to your use case, consider defining your own.
case inv: IllegalArgumentException => throw new Exception()
case inv: IllegalArgumentException => throw new UseCaseSpecificException()