global-error-handling

coreyja 的头像作者 coreyja

使用用户友好的消息、特定异常类型、集中式错误边界和优雅降级策略实现健壮的错误处理。在应用程序任何部分实现错误处理逻辑时使用此技能。编写try-catch块、错误边界或异常处理程序时。验证输入并使用清晰的错误消息快速失败时。处理API错误、网络故障或外部服务超时时。实现具有指数退避的重试策略时。确保在finally块中正确清理资源时。向用户显示错误消息而不暴露技术细节时。此技能适用于前端和后端代码的所有错误处理。

📖 中文导读:使用用户友好的消息、特定异常类型、集中式错误边界和优雅降级策略实现健壮的错误处理。在应用程序任何部分实现错误处理逻辑时使用此技能。编写try-catch块、错误边界或异常处理程序时。验证输入并使用清晰的错误消息快速失败时。处理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 implementing error handling logic in any part of the application. When writing try-catch blocks, error boundaries, or exception handlers. When validating input and failing fast with clear error messages. When handling API errors, network failures, or external service timeouts. When implementing retry strategies with exponential backoff. When ensuring resources are properly cleaned up in finally blocks. When displaying error messages to users without exposing technical details. This skill applies to all error handling across frontend and backend code.

Global Error Handling

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.

When to use this skill

  • When implementing error handling logic in any application code
  • When writing try-catch blocks or error boundaries in components
  • When handling API errors, network failures, or timeout scenarios
  • When validating input and failing fast with explicit error messages
  • When implementing retry strategies with exponential backoff for transient failures
  • When cleaning up resources (file handles, connections, locks) in finally blocks
  • When using specific exception types rather than generic error classes
  • When designing systems with graceful degradation for non-critical service failures
  • When centralizing error handling at controller, API, or component boundaries
  • When displaying user-friendly error messages without exposing security information

Instructions

For details, refer to the information provided in this file: global error handling