Methods are forbidden to throw RuntimeException
or Exception
; handling these exceptions requires catching RuntimeException
, which is forbidden in guideline EXC14-J. Catch specific exceptions as opposed to rather than the more general RuntimeException or Exception. Moreover, throwing a RuntimeException
can lead to subtle errors, for instance, a caller cannot examine the exception to determine why it was thrown, and consequently cannot attempt recovery.
...
To handle the case of passing in a null
string parameter, code calling this method may require catching RuntimeException
, which is a violation of guideline EXC14-J. Catch specific exceptions as opposed to rather than the more general RuntimeException or Exception.
...
EXC12-J. Do not log unsanitized user input 06. Exceptional Behavior (EXC) EXC14-J. Catch specific exceptions as opposed to rather than the more general RuntimeException or Exception