Skill: java-exception-robustness
Activation Contract
Use this skill when reviewing or designing Java exception handling, resource cleanup, checked/unchecked exception choices, failure boundaries, retry/fallback policy, and robust service behavior.
Do not use this skill for logging-only changes, security-only auditing, non-Java error models, or framework-specific exception mapping with no Java design question.
Responsibility
This skill teaches Java failure-handling design. It does not call other skills, hide failures by default, or invent business recovery policies.
Required Context
- Operation being protected.
- Who can recover from failures.
- Resource ownership and cleanup needs.
- Whether this is library, application, batch, or long-running service code.
- Sensitive-data constraints in messages/logs.
Context Budget
- Keep this
SKILL.md focused on error boundaries.
- Use
references/java-exception-guidance.md for detailed choices.
Hard Rules
- Do not swallow exceptions silently.
- Release resources deterministically with try-with-resources or
finally.
- Catch exceptions only where you can add context, recover, translate boundary errors, or enforce cleanup.
- Preserve stack traces when wrapping unless there is a deliberate boundary sanitization.
- Do not expose sensitive internal data in exception messages returned to users.
- Define boundary policy for long-running services: discard unit of work, log safely, cleanup, and continue or stop.
Decision Gates
| Condition |
Action |
| Resource acquired |
Use try-with-resources or explicit finally cleanup. |
| Caller can recover |
Use checked exception or documented recoverable result. |
| Caller cannot recover |
Use unchecked exception or boundary translation. |
| Exception crosses trust/user boundary |
Sanitize message and preserve internal diagnostics safely. |
| Broad catch appears |
Allow only at orchestration boundary with clear policy. |
Execution Steps
- Identify failure sources and recovery owner.
- Map resource acquisition and release.
- Choose catch/propagate/wrap/translate behavior.
- Check message sensitivity and logging policy.
- Return a robust failure-handling plan or code shape.
Output Contract
Return:
- Failure boundary verdict.
- Exception strategy and recovery owner.
- Resource cleanup requirements.
- Message/logging sensitivity notes.
- Example handling shape when useful.
References
references/java-exception-guidance.md — Exception choices, cleanup, and boundary policy.
Assets
1---2name: java-exception-robustness3description: Trigger: Java exceptions, error handling, try-with-resources, resource cleanup, checked exceptions, robustness. Design Java failure handling safely.4license: MIT5---67# Skill: java-exception-robustness89## Activation Contract1011Use this skill when reviewing or designing Java exception handling, resource cleanup, checked/unchecked exception choices, failure boundaries, retry/fallback policy, and robust service behavior.1213Do **not** use this skill for logging-only changes, security-only auditing, non-Java error models, or framework-specific exception mapping with no Java design question.1415## Responsibility1617This skill teaches Java failure-handling design. It does not call other skills, hide failures by default, or invent business recovery policies.1819## Required Context2021- Operation being protected.22- Who can recover from failures.23- Resource ownership and cleanup needs.24- Whether this is library, application, batch, or long-running service code.25- Sensitive-data constraints in messages/logs.2627## Context Budget2829- Keep this `SKILL.md` focused on error boundaries.30- Use `references/java-exception-guidance.md` for detailed choices.3132## Hard Rules3334- Do not swallow exceptions silently.35- Release resources deterministically with try-with-resources or `finally`.36- Catch exceptions only where you can add context, recover, translate boundary errors, or enforce cleanup.37- Preserve stack traces when wrapping unless there is a deliberate boundary sanitization.38- Do not expose sensitive internal data in exception messages returned to users.39- Define boundary policy for long-running services: discard unit of work, log safely, cleanup, and continue or stop.4041## Decision Gates4243| Condition | Action |44|---|---|45| Resource acquired | Use try-with-resources or explicit finally cleanup. |46| Caller can recover | Use checked exception or documented recoverable result. |47| Caller cannot recover | Use unchecked exception or boundary translation. |48| Exception crosses trust/user boundary | Sanitize message and preserve internal diagnostics safely. |49| Broad catch appears | Allow only at orchestration boundary with clear policy. |5051## Execution Steps52531. Identify failure sources and recovery owner.542. Map resource acquisition and release.553. Choose catch/propagate/wrap/translate behavior.564. Check message sensitivity and logging policy.575. Return a robust failure-handling plan or code shape.5859## Output Contract6061Return:6263- Failure boundary verdict.64- Exception strategy and recovery owner.65- Resource cleanup requirements.66- Message/logging sensitivity notes.67- Example handling shape when useful.6869## References7071- `references/java-exception-guidance.md` — Exception choices, cleanup, and boundary policy.7273## Assets7475- None.