agentsclimarketplace

Api error handling

Skill ulpi-io/plugin-marketplace/plugins/aj-geddes/skills/api-error-handling

A curated collection of 7,800+ agent skills for Claude Desktop, sourced from skills.sh

Install
npx -y skills add ulpi-io/plugin-marketplace --skill api-error-handling

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Implement comprehensive API error handling with standardized error responses, logging, monitoring, retry logic, and validation patterns. Use when building resilient APIs, debugging issues, improving error reporting, implementing retry logic, handling HTTP error codes, managing API timeouts, designing error response handling, or adding circuit breaker patterns.

SKILL.md

3.7 KB, as published. Nobody here has run it

API Error Handling

Table of Contents

Overview

Build robust error handling systems with standardized error responses, detailed logging, error categorization, and user-friendly error messages. This skill covers the full lifecycle from throwing typed errors through logging, monitoring, and client-facing response formatting.

When to Use

  • Handling API errors consistently across endpoints
  • Debugging production issues with request tracing
  • Implementing error recovery strategies (retry, circuit breaker)
  • Monitoring and alerting on error rates
  • Providing meaningful, actionable error messages to clients
  • Validating request inputs before processing
  • Tracking error patterns over time

Quick Start

Minimal standardized error response format:

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Input validation failed",
    "statusCode": 422,
    "requestId": "req_abc123xyz789",
    "timestamp": "2025-01-15T10:30:00Z",
    "details": [
      { "field": "email", "message": "Invalid email format", "code": "INVALID_EMAIL" }
    ]
  }
}

Custom error class (Node.js):

class ApiError extends Error {
  constructor(code, message, statusCode = null, details = null) {
    super(message);
    this.code = code;
    this.statusCode = statusCode || ERROR_CODES[code]?.status || 500;
    this.details = details;
    this.timestamp = new Date().toISOString();
  }
}

// Usage
throw new ApiError("NOT_FOUND", "User not found", 404);
throw new ApiError("VALIDATION_ERROR", "Missing fields", 422, fieldErrors);

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Error Codes & Response FormatComplete ERROR_CODES map, response formatter, global middleware (Node.js + Python)
Retry Strategies & Circuit BreakerExponential backoff, jitter, circuit breaker pattern
Monitoring & TrackingSentry integration, error rate metrics, /metrics/errors endpoint
Validation PatternsInput validation, schema guards, detecting bad responses before errors occur

Best Practices

✅ DO

  • Use a consistent error response format across all endpoints
  • Include requestId and traceId in every error for observability
  • Log 5xx errors at ERROR level; log 4xx at WARN level
  • Provide actionable error messages — tell the client what to fix
  • Use standard HTTP status codes (4xx client errors, 5xx server errors)
  • Implement retry with exponential backoff for transient failures
  • Use circuit breakers to prevent cascade failures
  • Validate inputs early and return all field errors at once
  • Monitor error rates and alert on anomalous spikes

❌ DON'T

  • Expose stack traces or internal implementation details to clients
  • Return HTTP 200 for error responses
  • Silently swallow errors
  • Log sensitive data (passwords, tokens, PII)
  • Use vague messages like "Something went wrong"
  • Mix error handling logic with business logic
  • Retry non-idempotent operations or client errors (4xx)
  • Return different error shapes from different endpoints

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.