global-error-handling

实现全面的错误处理策略,包括try-catch块、API错误响应、Content Collection错误处理、自定义错误页面和生产环境错误监控。在处理数据获取错误、API路由错误、验证失败或实现错误边界时使用此技能。在处理具有适当HTTP状态码的API路由错误响应、带有try-catch错误处理的数据获取逻辑、Content Collection getEntry/getCollection错误处理、自定义错误页面(404.astro, 500.astro)、React错误边界(用于客户端组件)、客户端脚本错误处理、错误记录和监控集成(Sentry)、构建时错误处理或带有指数退避的重试逻辑时使用。

📖 中文导读:实现全面的错误处理策略,包括try-catch块、API错误响应、Content Collection错误处理、自定义错误页面和生产环境错误监控。在处理数据获取错误、API路由错误、验证失败或实现错误边界时使用此技能。在处理具有适当HTTP状态码的API路由错误响应、带有try-catch错误处理的数据获取逻辑、Content Collection getEntry/getCollection错误处理、自定义错误页面(404.astro, 500.astro)、React错误边界(用于客户端组件)、客户端脚本错误处理、错误记录和监控集成(Sentry)、构建时错误处理或带有指数退避的重试逻辑时使用。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: Global Error Handling description: Implement comprehensive error handling strategies including try-catch blocks, API error responses, Content Collection error handling, custom error pages, and production error monitoring. Use this skill when handling data fetching errors, API route errors, validation failures, or implementing error boundaries. When working on API route error responses with proper HTTP status codes, data fetching logic with try-catch error handling, Content Collection getEntry/getCollection error handling, custom error pages (404.astro, 500.astro), React Error Boundaries for client-side components, client-side script error handling, error logging and monitoring integration (Sentry), build-time error handling, or retry logic with exponential backoff.

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 writing API routes that need consistent error responses with proper HTTP status codes
  • When implementing data fetching logic that requires try-catch error handling
  • When using Content Collections getEntry or getCollection methods
  • When creating custom error pages (src/pages/404.astro, 500 error pages)
  • When implementing React Error Boundaries for client-side component errors
  • When writing client-side scripts that need error handling and logging
  • When integrating error monitoring tools like Sentry for production tracking
  • When handling build-time errors or Content Collection schema validation failures
  • When implementing retry logic with exponential backoff for transient failures
  • When ensuring graceful degradation for non-critical feature failures
  • When logging errors with appropriate context and severity levels

Instructions

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