skillfed

error-handling-patterns

This skill covers error handling strategies for building resilient applications across multiple languages. Learn when to use exceptions versus Result types, how to categorize recoverable and unrecoverable errors, and implement patterns like retry with exponential backoff and async error handling. Includes language-specific examples for Python, TypeScript, and Rust.

Error Handling Patterns teaches resilient error management across Python, TypeScript, and Rust using exceptions, Result types, and recovery strategies.

AI-generated summary based on this skill's SKILL.md

86 12 MIT updated by HermeticOrmus

Install

HermeticOrmus/LibreUIUX-Claude-Code/error-handling-patterns · repository language: Shell

git clone https://github.com/HermeticOrmus/LibreUIUX-Claude-Code
cp -r LibreUIUX-Claude-Code/plugins/developer-essentials/skills/error-handling-patterns ~/.claude/skills/error-handling-patterns
npx skillfed install HermeticOrmus/LibreUIUX-Claude-Code/error-handling-patterns

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How to handle errors in Python effectively?

error-handling-patterns teaches Python error handling through try-except blocks, custom exception hierarchies, and context managers for cleanup. The skill covers distinguishing between recoverable errors (retry candidates) and unrecoverable ones, using specific exception types rather than bare except clauses, and implementing graceful degradation when errors occur. Python examples show proper exception chaining and resource management patterns.

What is the circuit breaker pattern and when should I use it?

error-handling-patterns explains the circuit breaker pattern as a resilience mechanism that prevents cascading failures by stopping requests to failing services. The pattern has three states: closed (normal operation), open (failing, reject requests), and half-open (testing recovery). This skill teaches implementation strategies for detecting failure thresholds, managing state transitions, and integrating circuit breakers into retry logic for fault-tolerant systems.

How do Result types compare to exceptions for error handling?

error-handling-patterns contrasts Result types (used in Rust and TypeScript) with traditional exceptions. Result types make errors explicit in function signatures and force callers to handle them, while exceptions can be silently propagated. The skill covers when each approach excels: Results for predictable, recoverable errors; exceptions for unexpected failures. Examples show how languages like Rust use Result<T, E> for type-safe error handling.

How do I implement retry logic with exponential backoff?

error-handling-patterns demonstrates retry logic patterns that attempt failed operations multiple times with increasing delays between attempts. Exponential backoff multiplies the delay after each failure (e.g., 1s, 2s, 4s, 8s) to avoid overwhelming recovering services. The skill covers jitter addition to prevent thundering herd problems, maximum retry limits, and integration with circuit breakers for comprehensive resilience in distributed systems.

What are best practices for handling async and concurrent errors?

error-handling-patterns addresses async error handling across Promise-based systems (TypeScript/JavaScript) and concurrent patterns. Key practices include proper Promise rejection handling, avoiding unhandled rejections, using async/await with try-catch for readability, and managing errors in parallel operations. The skill teaches error aggregation when multiple async tasks fail, timeout handling for hanging operations, and context propagation in distributed tracing.

How should I design a custom exception hierarchy?

error-handling-patterns guides designing exception hierarchies that reflect your application's error domain. Start with a base custom exception, then create specific subclasses for different error categories (validation, network, database, authorization). The skill emphasizes including context (error codes, messages, original cause) and avoiding overly deep hierarchies. Examples show language-specific implementations in Python and TypeScript for maintainable, debuggable error handling.

SKILL.md

rendered from the published skill — quoted content, verbatim

Error Handling Patterns

Build resilient applications with robust error handling strategies that gracefully handle failures and provide excellent debugging experiences.

When to Use This Skill

  • Implementing error handling in new features
  • Designing error-resilient APIs
  • Debugging production issues
  • Improving application reliability
  • Creating better error messages for users and developers
  • Implementing retry and circuit breaker patterns
  • Handling async/concurrent errors
  • Building fault-tolerant distributed systems

Core Concepts

1. Error Handling Philosophies

Exceptions vs Result Types: - Exceptions: Traditional try-catch, disrupts control flow - Result Types: Explicit success/failure, functional approach - Error Codes: C-style, requires discipline - Option/Maybe Types: For nullable values

When to Use Each: - Exceptions: Unexpected

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 1 file
plugins/developer-essentials/skills/error-handling-patterns/SKILL.md

Related skills

Tags

resilience-patterns fault-tolerance error-recovery exception-design failure-handling defensive-coding reliability-engineering error-propagation system-robustness debugging-support