handling-api-errors

Featured

Implement standardized error handling with proper HTTP status codes and error responses. Use when implementing standardized error handling. Trigger with phrases like "add error handling", "standardize errors", or "implement error responses".

AI & Automation 2,359 stars 334 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Handling API Errors ## Overview Implement standardized API error handling with RFC 7807 Problem Details responses, centralized error middleware, typed error classes, and environment-aware stack trace exposure. Convert framework exceptions, validation failures, database errors, and upstream service failures into consistent, machine-readable error responses with appropriate HTTP status codes. ## Prerequisites - Web framework with middleware/error handler support (Express, FastAPI, Spring Boot, Gin) - Structured logging library for error event recording with correlation IDs - Error monitoring service: Sentry, Bugsnag, or Rollbar for production error tracking - RFC 7807 Problem Details specification for response format guidance - API documentation listing all possible error codes and their meanings ## Instructions 1. Audit existing error handling using Grep to find `try/catch` blocks, error middleware, and exception handlers, identifying inconsistent error response formats across endpoints. 2. Define a standardized error response envelope following RFC 7807: `type` (URI identifying error type), `title` (human-readable summary), `status` (HTTP code), `detail` (specific explanation), and `instance` (request path). 3. Create typed error classes for each error category: `ValidationError` (400), `AuthenticationError` (401), `AuthorizationError` (403), `NotFoundError` (404), `ConflictError` (409), and `RateLimitError` (429). 4. Implement centralized error handling middleware th...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
8 months ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category