global-error-handling
实现健壮的错误处理策略,提供友好的错误信息和优雅的失败模式。在捕获和处理异常、验证输入、检查函数预条件、向用户显示错误信息、在API层或控制器中实现集中式错误处理、使用特定异常类型而非通用错误、实现重试逻辑以处理短暂失败、确保错误场景中资源正确清理、设计系统在非关键服务失败时优雅降级时使用此技能。
📖 中文导读:实现健壮的错误处理策略,提供友好的错误信息和优雅的失败模式。在捕获和处理异常、验证输入、检查函数预条件、向用户显示错误信息、在API层或控制器中实现集中式错误处理、使用特定异常类型而非通用错误、实现重试逻辑以处理短暂失败、确保错误场景中资源正确清理、设计系统在非关键服务失败时优雅降级时使用此技能。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。
name: Global Error Handling description: Implement robust error handling strategies with user-friendly messages and graceful failure patterns. Use this skill when catching and handling exceptions or errors in any code. Use this skill when validating input and checking preconditions early in functions. Use this skill when displaying error messages to users. Use this skill when implementing centralized error handling in API layers or controllers. Use this skill when using specific exception types rather than generic errors. Use this skill when implementing retry logic for transient failures. Use this skill when ensuring proper resource cleanup in error scenarios. Use this skill when designing systems to degrade gracefully when non-critical services fail.
Global Error Handling
When to use this skill
- When implementing try-catch blocks or error handling logic
- When validating input and failing fast with clear error messages
- When displaying error messages to users without exposing technical details
- When using specific exception or error types for targeted handling
- When implementing centralized error handling at API or controller boundaries
- When designing graceful degradation for non-critical service failures
- When implementing retry strategies with exponential backoff
- When ensuring resource cleanup in finally blocks or equivalent mechanisms
- When handling errors across any language or framework in the project
This Skill provides Claude Code with specific guidance on how to adhere to coding standards as they relate to how it should handle global error handling.
Instructions
For details, refer to the information provided in this file: global error handling