Use when adding new error messages to React, or seeing "unknown error code" warnings.
npx skills add shipshitdev/library --skill "error-handling-expert"
Install specific skill from multi-skill repository
# Description
Expert in error handling patterns, exception management, error responses, logging, and error recovery strategies for React, Next.js, and NestJS applications
# SKILL.md
name: error-handling-expert
description: Expert in error handling patterns, exception management, error responses, logging, and error recovery strategies for React, Next.js, and NestJS applications
Error Handling Expert Skill
Expert in error handling patterns, exception management, error responses, logging, and error recovery strategies for React, Next.js, and NestJS applications.
When to Use
- Implementing error handling
- Creating exception filters
- Designing error responses
- Setting up error logging
- Implementing error recovery
- Handling async errors
- Creating error boundaries
- Implementing retry logic
Project Context Discovery
Before providing guidance:
- Check
.agent/SYSTEM/ARCHITECTURE.mdfor error patterns - Review existing exception filters
- Check for error monitoring (Sentry, Rollbar)
- Review logging libraries (Winston, Pino)
Core Principles
Error Types
Application Errors: 400, 401, 403, 404, 409, 422
System Errors: 500, 502, 503, 504
Error Response Format
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Validation failed",
"details": [...],
"timestamp": "2025-01-01T00:00:00Z",
"path": "/api/users",
"requestId": "req-123456"
}
}
Quick Patterns
NestJS Exception Filter
@Catch()
export class AllExceptionsFilter implements ExceptionFilter {
catch(exception: unknown, host: ArgumentsHost) {
// Log, format, respond
}
}
React Error Boundary
class ErrorBoundary extends React.Component {
componentDidCatch(error, errorInfo) {
// Log to monitoring
}
}
Retry with Backoff
async function retryWithBackoff<T>(fn, maxRetries = 3): Promise<T>
Best Practices
- User-friendly messages, no sensitive info
- Log all errors with context
- Integrate error monitoring (Sentry)
- Implement retry logic and circuit breakers
- Provide fallback values
- Test error cases
Recovery Strategies
- Retry Logic - Exponential backoff
- Circuit Breaker - Prevent cascade failures
- Fallback Values - Graceful degradation
For complete exception filter implementations, custom exceptions, validation pipe setup, error boundaries, circuit breaker pattern, logging integration, and database/API error patterns, see: references/full-guide.md
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.