global-error-handling
实现健壮的错误处理,包含用户友好的消息、特定异常类型(ISP)、集中式错误边界(SRP)、快速失败验证(KISS)、优雅降级、重试策略和适当的资源清理。在添加try-catch块、抛出或捕获异常、创建错误类、实现错误边界或中间件、向用户显示错误消息或处理异步错误和Promise拒绝时使用此技能。在处理任何语言(.ts、.js、.py、.java、.go)的错误处理时使用,包括后端服务、API端点、前端组件或数据处理管道。在实现指数退避或确保在finally块中清理资源时使用。
📖 中文导读:实现健壮的错误处理,包含用户友好的消息、特定异常类型(ISP)、集中式错误边界(SRP)、快速失败验证(KISS)、优雅降级、重试策略和适当的资源清理。在添加try-catch块、抛出或捕获异常、创建错误类、实现错误边界或中间件、向用户显示错误消息或处理异步错误和Promise拒绝时使用此技能。在处理任何语言(.ts、.js、.py、.java、.go)的错误处理时使用,包括后端服务、API端点、前端组件或数据处理管道。在实现指数退避或确保在finally块中清理资源时使用。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。
name: Global Error Handling description: Implement robust error handling with user-friendly messages, specific exception types (ISP), centralized error boundaries (SRP), fail-fast validation (KISS), graceful degradation, retry strategies, and proper resource cleanup. Use this skill when adding try-catch blocks, throwing or catching exceptions, creating error classes, implementing error boundaries or middleware, displaying error messages to users, or handling async errors and promise rejections. Use when working with error handling in any language (.ts, .js, .py, .java, .go) across backend services, API endpoints, frontend components, or data processing pipelines. Use when implementing exponential backoff for external service calls or ensuring resources are cleaned up in finally blocks.
Global Error Handling
This Skill provides Claude Code with specific guidance on error handling best practices across backend and frontend code, including KISS, ISP, and SRP principles.
When to use this skill
- When adding try-catch blocks or error handling logic to any code
- When throwing or catching exceptions/errors in any programming language
- When creating custom exception or error classes
- When implementing centralized error handling (middleware, error boundaries, global handlers)
- When displaying error messages to users in UI components
- When handling async errors and promise rejections
- When implementing retry strategies with exponential backoff
- When ensuring graceful degradation when non-critical services fail
- When validating input and failing fast with clear error messages (KISS)
- When using specific exception types instead of generic errors (ISP)
- When cleaning up resources in finally blocks or equivalent mechanisms
- When working with error handling in backend (.ts, .py, .java, .go) or frontend (.tsx, .jsx, .vue)
- When implementing error logging and monitoring
Instructions
For details, refer to the information provided in this file: global error handling