Identify and apply robust Java exception handling practices to improve error clarity, security, debuggability, and system reliability.
Prerequisites: Run ./mvnw compile or mvn compile before applying any changes. If compilation fails, stop immediately — do not proceed until the project is in a valid state.
Core areas: Specific exception types instead of generic Exception/RuntimeException, try-with-resources for automatic resource cleanup, secure exception messages that avoid information leakage, exception chaining to preserve full error context, early input validation with IllegalArgumentException/NullPointerException, InterruptedException handling with interrupted-status restoration, @throws JavaDoc documentation,...
Java 例外処理のベスト プラクティスを適用する必要がある場合に使用します。これには、特定の例外タイプの使用、try-with-resources によるリソースの管理、例外メッセージの保護、例外チェーンによるエラー コンテキストの保持、フェイルファスト原則による入力の早期検証、スレッド割り込みの適切な処理、@throws による例外の文書化、ロギング ポリシーの強制、API 境界での例外の変換、再試行と冪等性の管理、タイムアウトの強制、抑制された例外の添付、エラーの伝播などがあります。非同期/リアクティブコード。 Skills-for-Java プロジェクトの一部 ソース: jabrena/cursor-rules-java。