← ClaudeAtlas

error-handlinglisted

Design or implement error handling patterns — custom error classes, error boundaries, API error responses
SilviaAre95/wayworks · ★ 1 · AI & Automation · score 77
Install: claude install-skill SilviaAre95/wayworks
# Error Handling Design error handling for the specified scope: **$ARGUMENTS** (language/framework defaults to TypeScript) ## Steps 1. **Audit current state** — Read the existing error handling in the target scope. Identify: - Silent catches (`catch (e) {}` or `catch (e) { console.log(e) }`) - Inconsistent error shapes across endpoints - Missing error boundaries (React) or global handlers (API) - Leaked internal details in error responses 2. **Design error hierarchy** — Create a structured error system: ```typescript // Base application error class AppError extends Error { constructor( message: string, public code: string, public statusCode: number = 500, public isOperational: boolean = true ) { super(message); this.name = this.constructor.name; } } // Specific errors class ValidationError extends AppError { constructor(message: string, public fields?: Record<string, string>) { super(message, "VALIDATION_ERROR", 400); } } class NotFoundError extends AppError { constructor(resource: string, id?: string) { super( id ? `${resource} with id ${id} not found` : `${resource} not found`, "NOT_FOUND", 404 ); } } class UnauthorizedError extends AppError { constructor(message = "Authentication required") { super(message, "UNAUTHORIZED", 401); } } class ForbiddenError extends AppError { constructor(message = "Insufficient permissions") { super(message, "FORBIDDEN", 403); } } ``` 3. *