error-handling

Implement structured error hierarchies with retry, circuit breaker, and fallback strategies.

53|1|Updated Dec 18, 2025
One-click install
npx skills add https://github.com/cosmix/claude-code-setup --skill error-handling-cosmix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: error-handling
Source: https://github.com/cosmix/claude-code-setup/tree/main/skills/error-handling
Command: npx skills add https://github.com/cosmix/claude-code-setup --skill error-handling-cosmix

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides structured error hierarchies, retry strategies, fallbacks, and logging practices to make apps more robust and user-friendly.

Core Features & Use Cases

  • Error Hierarchies: Clear categories (validation, not found, service error).
  • Recovery Strategies: Retry with backoff, circuit breakers, and graceful fallbacks.
  • User-Friendly Messaging: Consistent error responses with context.

Quick Start

Implement a retry-with-backoff wrapper around a flaky HTTP call and expose a friendly error to the user.

Frequently Asked Questions about error-handling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement retry logic with exponential backoff for failing API calls?

Retry with exponential backoff automatically re-attempts failed requests with increasing delays between attempts. Define a retry policy specifying max attempts and backoff multiplier, wrap your HTTP call, and let the handler manage retries before surfacing the error to users.

What's the best way to structure error types across my application?

Create a hierarchy of error types that categorizes failures—validation errors, not-found, service errors—so callers can handle each category appropriately. Structured types make recovery decisions deterministic and enable consistent logging and user messaging.

How do circuit breakers prevent cascading failures in distributed systems?

A circuit breaker monitors calls to a failing service and stops sending requests once a threshold is reached, allowing the service time to recover. It transitions between closed (normal), open (blocking), and half-open (testing) states to prevent resource exhaustion and propagation of failures downstream.

How do I design user-friendly error messages that don't expose internal details?

Separate internal error context from public-facing messages. Log full error details for debugging, but return only actionable, non-technical messages to users—for example, "Please try again later" instead of database stack traces.

When should I use fallback strategies instead of retrying?

Use fallbacks when a service is genuinely unavailable or slow and retries would waste resources. Fallbacks provide degraded but functional responses—cached data, default values, or alternate endpoints—so users experience resilience rather than timeouts.

How do I propagate and enrich errors as they bubble up through layers?

Wrap errors at each layer, preserving the original cause while adding context relevant to that layer—request ID, operation name, user input. Error enrichment creates a chain of custody that aids debugging without losing the root cause.