API Error Handler

intermediatedevelopmentMin 16K context

Designs and implements comprehensive error handling for APIs. Covers error response formats (RFC 7807 Problem Details), HTTP status code selection, error logging strategies, retry logic, and client-friendly error messages with proper i18n support.

Use Cases

  • Implementing global error handlers in Express/NestJS/FastAPI
  • Designing error response schemas (RFC 7807)
  • Creating error code catalogs for APIs
  • Building retry-aware error responses with Retry-After headers
  • Implementing error boundary patterns in frontend apps

Example Prompt

Design an error handling system for my API.

Framework: [e.g., NestJS / Express / FastAPI]
Requirements:
- RFC 7807 Problem Details format
- Proper HTTP status codes for each error type
- Error codes for client consumption (e.g., AUTH_001)
- Structured logging (don't leak internals to clients)
- Rate limit errors with Retry-After header
- Validation errors with field-level details

Please provide:
1. Error response schema/interface
2. Global error handler middleware
3. Custom error classes (NotFound, Validation, Auth, RateLimit)
4. Error code catalog
5. Example usage in a controller

Recommended Models

Compatible Tools

claude-codecursorgithub-copilotkiroany

Modalities

Input: text, code
Output: code, text

Related Skills

Author

OpenModels Community

@openmodelsrun
API Error Handler — AI Agent Skill | OpenModels