126-java-exception-handling

仓库创建 2025年2月9日最近提交 3 天前SkillHot 收录 21 天前
▸ 精选理由

提高错误可诊断性并避免敏感信息泄露,适合生产代码改进。

这个 Skill 做什么

改进 Java 异常处理实践:具体异常、try-with-resources 与异常链保留上下文。

把异常处理从杂乱变清晰:用具体异常、try-with-resources 自动释放资源,并通过异常链保留上下文。会在改进错误消息安全性、实现 fail‑fast 校验、处理中断或在 API 边界翻译异常时用到。对异步/响应式场景的异常传播、重试与超时也给出实用做法。

▸ 展开 SKILL.md 英文原文

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 suppressed exceptions, and propagating failures in async/reactive code. This should trigger for requests such as Exception handling; Use try-with-resources in Java code; Create exception chaining in Java code; Apply fail-fast validation in Java code; Review Java exception taxonomy and propagation. Part of Plinth Toolkit

开发编程异常处理资源管理诊断通用
423
Stars
89
Forks
40
仓库内 Skill
+9
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/jabrena/plinth/main/skills/126-java-exception-handling/SKILL.md
或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/jabrena/plinth/main/skills/126-java-exception-handling/SKILL.md"
SKILL.MD 节选查看完整文件 ↗
# 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
- `@throws` JavaDoc documentation, fail-fast principle
- Structured logging with correlation IDs, av
via SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有