global-error-handling
Implement robust error handling with user-friendly messages, fail-fast validation, specific exception types, and proper resource cleanup across the application. Use this skill when writing try-catch blocks, throwing or catching exceptions, implementing error boundaries, handling API errors, or managing error states in any part of the codebase. Apply this skill when validating inputs early (fail fast), providing clear actionable error messages to users without exposing security details, using specific exception types rather than generic errors, implementing centralized error handling at appropriate boundaries, designing for graceful degradation, implementing retry logic with exponential backoff, or ensuring resources are cleaned up in finally blocks. This skill ensures errors are caught and handled appropriately, user experience remains positive even when errors occur, security is maintained by not leaking sensitive information, and systems continue operating or degrade gracefully when non-critical services fa
When & Why to Use This Skill
This Claude skill enables the implementation of a robust, system-wide error handling framework designed to enhance application resilience and security. It focuses on fail-fast validation, specific exception modeling, and centralized management to ensure that software remains stable under failure conditions while providing a seamless, professional user experience.
Use Cases
- API Resilience: Implementing automated retry logic with exponential backoff for transient network failures and external service dependencies.
- Frontend Stability: Developing centralized error boundaries in frameworks like React to catch runtime exceptions and prevent application-wide crashes.
- Security & UX: Crafting actionable user-facing error messages that guide the user without exposing sensitive system internals or stack traces.
- Resource Management: Ensuring critical system resources, such as database connections and file handles, are reliably released using standardized try-finally patterns.
- Code Maintainability: Replacing generic error catching with domain-specific exception types (e.g., ValidationError, NotFoundError) to improve debugging and system observability.
| name | Global Error Handling |
|---|---|
| description | Implement robust error handling with user-friendly messages, fail-fast validation, specific exception types, and proper resource cleanup across the application. Use this skill when writing try-catch blocks, throwing or catching exceptions, implementing error boundaries, handling API errors, or managing error states in any part of the codebase. Apply this skill when validating inputs early (fail fast), providing clear actionable error messages to users without exposing security details, using specific exception types rather than generic errors, implementing centralized error handling at appropriate boundaries, designing for graceful degradation, implementing retry logic with exponential backoff, or ensuring resources are cleaned up in finally blocks. This skill ensures errors are caught and handled appropriately, user experience remains positive even when errors occur, security is maintained by not leaking sensitive information, and systems continue operating or degrade gracefully when non-critical services fail. |
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 try-catch-finally blocks or exception handling logic
- When throwing custom errors or exceptions with meaningful messages
- When validating inputs and failing fast on invalid data
- When implementing error boundaries in React or error handling middleware
- When handling API errors, network failures, or external service calls
- When providing user-facing error messages that are clear and actionable
- When logging errors with appropriate context (stack traces, user actions, timestamps)
- When implementing retry strategies with exponential backoff for transient failures
- When ensuring resource cleanup (file handles, database connections, network sockets)
- When centralizing error handling at API controllers, service boundaries, or UI error boundaries
- When designing systems to degrade gracefully when non-critical services fail
- When avoiding exposing sensitive information (stack traces, internal paths) to end users
- When using specific exception types (ValidationError, NotFoundError) instead of generic ones
- When implementing proper error propagation without swallowing errors silently
Instructions
For details, refer to the information provided in this file: global error handling