Methods must not throw RuntimeException
or Exception
. Handling these exceptions requires catching RuntimeException
, which is disallowed by rule ERR14-J. Do not catch RuntimeExceptionNullPointerException. Moreover, throwing a RuntimeException
can lead to subtle errors, for example, a caller cannot examine the exception to determine why it was thrown, and consequently cannot attempt recovery.
...
A calling method must violate also rule ERR14-J. Do not catch RuntimeExceptionNullPointerException to determine if the RuntimeException
was thrown.
...
ERR11-J. Restore prior object state on method failure 06. Exceptional Behavior (ERR) ERR14-J. Do not catch RuntimeExceptionNullPointerException