Agent skill · software engineering · jeremylongshore

handling-api-errors

Implement standardized error handling with proper HTTP status codes

Why this skill is useful

Adds executable scripts for centralized error handling middleware and typed error classes that standardize API error responses.

What it needs

Requires grep installed locally. About 3k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.

What this skill does

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 that catches all thrown errors, maps them to the appropriate HTTP status code and RFC 7807 body, and prevents raw stack traces from leaking to clients. 5. Add validation error formatting that transforms framework-specific validation failures into a consistent array of field-level errors with field, message, and code properties. 6. Configure environment-aware error detail: include stack traces and internal error codes in development/staging responses; omit them in production while logging the full error server-side. 7. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills jeremylongshore/handling-api-errors--dbd5e1

View the source on GitHub

Browse the @skills marketplace