global-error-handling
实现健壮的错误处理,包括用户友好的消息、特定的异常类型、集中的错误边界和优雅降级策略。在使用此技能时包括编写try-catch块、处理异常和错误、为用户创建错误消息、在React或其他框架中实现错误边界、验证输入和检查前提条件、处理API错误和外部服务故障、实现带有指数退避的重试策略、在finally块中清理资源、为非关键故障设计优雅降级,或防止技术细节和安全信息暴露给用户。在任何代码文件中处理错误、实现错误恢复机制或审查错误处理方法以增强健壮性和安全性时应用此技能。
📖 中文导读:实现健壮的错误处理,包括用户友好的消息、特定的异常类型、集中的错误边界和优雅降级策略。在使用此技能时包括编写try-catch块、处理异常和错误、为用户创建错误消息、在React或其他框架中实现错误边界、验证输入和检查前提条件、处理API错误和外部服务故障、实现带有指数退避的重试策略、在finally块中清理资源、为非关键故障设计优雅降级,或防止技术细节和安全信息暴露给用户。在任何代码文件中处理错误、实现错误恢复机制或审查错误处理方法以增强健壮性和安全性时应用此技能。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。
name: Global Error Handling description: Implement robust error handling with user-friendly messages, specific exception types, centralized error boundaries, and graceful degradation strategies. Use this skill when writing try-catch blocks, handling exceptions and errors, creating error messages for users, implementing error boundaries in React or other frameworks, validating input and checking preconditions, handling API errors and external service failures, implementing retry strategies with exponential backoff, cleaning up resources in finally blocks, designing graceful degradation for non-critical failures, or preventing technical details and security information from being exposed to users. Apply this skill when handling errors in any code file, implementing error recovery mechanisms, or reviewing error handling approaches for robustness and security.
Global Error Handling
When to use this skill
- When writing try-catch blocks or error handling logic in any file
- When handling exceptions and errors from external services or APIs
- When creating error messages that will be displayed to users
- When implementing error boundaries in React or similar frameworks
- When validating input and checking preconditions early in functions
- When using specific exception or error types instead of generic ones
- 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 cleaning up resources (connections, file handles) in finally blocks
- When ensuring error messages don't expose technical details or security information
- When reviewing error handling for completeness and security
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