This rule identifies when exceptions are raised within a catch block but are not relevant to the exception parameter specified in the catch block. This can result in the original exception’s stack trace information being lost, which leads to throwing less detailed exceptions.
Non-Compliant Code Examples
publicclassFoo{voidfoo(){try{Integer.parseInt("foo");}catch(Exceptione){thrownewException(e.getMessage());// only throwing the message here}}}
Compliant Code Examples
publicclassFoo{voidfoo(){try{Integer.parseInt("foo");}catch(Exceptione){thrownewException(e);// sending the full exception at least}}}
シームレスな統合。 Datadog Code Security をお試しください
Datadog Code Security
このルールを試し、Datadog Code Security でコードを解析する
このルールの使用方法
1
2
rulesets:- java-best-practices # Rules to enforce Java best practices.