Java


JAVA.STRUCT.EXCP.BROAD : Broad Throws Clause (Java)

要旨

The throws clause of a method or constructor declares a very generic exception type.

This checker controls if exception handlers might be incorrect. For instance, an exception handler with an empty body might be an unfinished snippet of code; an exception handler for a very generic exception type might end up catching too many exceptions, also some that were not meant to be caught there.

プロパティ

クラス名 Broad Throws Clause (Java)
日本語クラス名 Broad Throws Clause (Java)
クラス分類 信頼性 (reliability)
ニーモニック JAVA.STRUCT.EXCP.BROAD
カテゴリー
CWE CWE:397 Declaration of Throws for Generic Exception
CERT-Java CERT-Java:ERR07-J Do not throw RuntimeException, Exception, or Throwable
対応言語 Java で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Broad Throws Clause (Java)"

解決法

Add a body to the exception handler, or narrow to the exception types.

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。