
Api Error Handling
A solid foundation for production API error handling with standardized JSON responses, proper status codes, and request tracing. Includes a custom error class with static helpers for common scenarios, a global Express middleware handler, and a circuit breaker implementation for dealing with flaky downstream services. The code is opinionated in the right ways: shields users from stack traces, separates client from server errors, and includes request IDs for debugging. If you're tired of inconsistent error formats across your endpoints or need to add resilience patterns without reinventing the wheel, this gives you the scaffolding. Python Flask examples are included in the references.
- skills.sh installs
- 455
- GitHub stars
- 248
- last updated
- Aug 21, 2026
Install
$ npx -y skills add secondsky/claude-skills --skill api-error-handling --agent claude-codeInstalls into .claude/skills of the current project.
Files
API Error Handling
Implement robust error handling with standardized responses and proper logging.
Standard Error Response Format
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request parameters",
"status": 400,
"requestId": "req_abc123",
"timestamp": "2025-01-15T10:30:00Z",
"details": [
{ "field": "email", "message": "Invalid email format" }
]
}
}
Error Class (Node.js)
class ApiError extends Error {
constructor(code, message, status = 500, details = null) {
super(message);
this.code = code;
this.status = status;
this.details = details;
}
static badRequest(message, details) {
return new ApiError('BAD_REQUEST', message, 400, details);
}
static notFound(resource) {
return new ApiError('NOT_FOUND', `${resource} not found`, 404);
}
static unauthorized() {
return new ApiError('UNAUTHORIZED', 'Authentication required', 401);
}
}
Sponsors
Details
- Repository
- github.com/secondsky/claude-skills
- Categories
- Backend & APIs, DevOps & CI/CD, Debugging
- First seen
- Jun 3, 2026
More from secondsky/claude-skills
All 146- Internationalization I18n455
- Security Headers Configuration454
- Seo Optimizer453
- Sequential Thinking448
- Bun Sqlite442
- Websocket Implementation440
- Mobile App Debugging439
- Root Cause Tracing438
- App Store Deployment437
- Database Schema Design437
- Recommendation Engine437
- Seo Keyword Cluster Builder437
- Bun Sveltekit436
- Push Notification Setup436
- Drizzle Orm D1435
- Api Response Optimization434
- Api Pagination433
- Api Filtering Sorting432
- Defense In Depth Validation430
- Session Management427
- Ultracite426
- Nuxt Production425
- Api Gateway Configuration422
- Oauth Implementation422