Error Handling Boilerplate

Version: 1.0 Added: Jan 21, 2026

Description

Generates comprehensive error handling code including custom error classes, try-catch blocks, error middleware, and user-friendly error messages.

Code

Skill Code
Error handling includes:
1. Custom error classes (ValidationError, NotFoundError)
2. Global error handler middleware
3. Async wrapper "keyword">for route handlers
4. Error logging with context
5. User-friendly error responses
6. Error codes "keyword">for client handling

Usage Examples

Examples
User: add error handling to my Express API

Claude: *creates files*
```javascript
// errors/AppError.js
"keyword">class AppError extends Error {
  constructor(message, statusCode, code) {
    super(message);
    this.statusCode = statusCode;
    this.code = code;
    this.isOperational = true;
  }
}

// middleware/errorHandler.js
"keyword">const errorHandler = (err, req, res, next) => {
  // ... handles all error types
};
```

Installation

Add the following to your CLAUDE.md file (project root or ~/.claude/CLAUDE.md for global):

CLAUDE.md
# Error Handling Boilerplate

Error handling includes:
1. Custom error classes (ValidationError, NotFoundError)
2. Global error handler middleware
3. Async wrapper for route handlers
4. Error logging with context
5. User-friendly error responses
6. Error codes for client handling

Comments (0)

No comments yet. Be the first to share your thoughts!