Your description for RuntimeException(unchecked exceptions) is not accurate in rule s112.
is telling following:
" Throwing generic exceptions such as
Error
,RuntimeException
,Throwable
, andException
will have a negative impact on any code trying to catch these exceptions.From a consumer perspective, it is generally a best practice to only catch exceptions you intend to handle."
If you will check official documentation supplied for RuntimeException or any other java unchecked exception, on official site:
Description for RuntimeException is following:
“Runtime exceptions represent problems that are the result of a programming problem, and as such, the API client code cannot reasonably be expected to recover from them or to handle them in any way.”
You telling that RuntimeException are intended to be handled, however official Java documentation tells that it is not - so there is a contradiction between official Java unchecked exception semantic, and description you providing, as result your rule provides wrong suggestion how to define unchecked exception in the code.
From coding perspective it is common practice to wrap checked into runtime exception to stop operation execution if operation cannot recover from checked exception, and there is no proper way to handle in the code and just to return an error to user
try {
// some code goes here
} catch(IOException ex) {
throw new RuntimeException(ex);
}