Use when you need to apply Java exception handling best practices — including using specific exception types, managing resources with try-with-resources, securing exception messages, preserving error context via exception chaining, validating inputs early with fail-fast principles, handling thread interruption correctly, documenting exceptions with @throws, enforcing logging policy, translating exceptions at API boundaries, managing retries and idempotency, enforcing timeouts, attaching suppress
NewMaintained
Automatic
◆Coding pack
Last verified 8/20/2026
What it changes
Passed 0 of 16 test cases with the skill, and 16 of 16 without it.
Without skill100%
With skill0%
Checks it passed that the model alone missed
Executes `./mvnw clean verify` or `mvn clean verify` to validate changes
1 fixed13 passed either way3 still failing5 broke
Pass-rate lift
-100 pp
Tokens
-11%
Agent turns
0%
Response time
-37%
Model gemini-3.6-flashMeasured 8/20/2026v114 of 22 cases passed with skill · 16 comparable
Tokens, turns and time describe resource use, not a dollar price.
See it in action
A test case the skill fixed. Same model, same prompt, with and without the skill.
Prompt
We just finished updating the exception taxonomy across the inventory module. What build step must be executed to confirm safety and correctness before committing?
What was checked, without and with the skill
Checked
Without skill
With skill
Executes `./mvnw clean verify` or `mvn clean verify` to validate changes
Missed
Passed
case-19 · gemini-3.6-flash · 8/20/2026 · answers are capped and redacted
What's inside
The instructions your model reads when the skill loads.
SKILL.md62 lines2 files
Java Exception Handling Guidelines
Identify and apply robust Java exception handling practices to improve error clarity, security, debuggability, and system reliability.
What is covered in this Skill?
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
Structured logging with correlation IDs, avoiding log-and-throw duplication
API boundary translation via centralized exception mappers
Bounded retry with backoff for idempotent operations only
Timeout enforcement with deadline propagation
Throwable#addSuppressed for secondary cleanup failures
Never catching Throwable/Error
Observability via error metrics
Failure propagation in async CompletionStage code
Scope: The reference is organized by examples (good/bad code patterns) for each core area. Apply recommendations based on applicable examples.
Constraints
Before applying any exception handling changes, ensure the project compiles. If compilation fails, stop immediately — do not proceed until resolved. After applying improvements, run full verification.
MANDATORY: Run ./mvnw compile or mvn compile before applying any changes
SAFETY: If compilation fails, stop immediately — do not proceed until the project is in a valid state
VERIFY: Run ./mvnw clean verify or mvn clean verify after applying improvements
BEFORE APPLYING: Read the reference for detailed good/bad examples, constraints, and safeguards for each exception handling pattern
Use when you need to review, improve, or write Java unit tests — including migrating from JUnit 4 to JUnit 5, adopting AssertJ for fluent assertions, structuring tests with Given-When-Then, ensuring test independence, applying parameterized tests, mocking dependencies with Mockito, verifying boundary conditions (RIGHT-BICEP, CORRECT, A-TRIP), leveraging JSpecify null-safety annotations, or eliminating testing anti-patterns such as reflection-based tests or shared mutable state. This should trigg