error-handling-patterns

Implement error handling patterns across Python, TypeScript, Rust, and Go applications.

Updated Apr 23, 2026
One-click install
npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill error-handling-patterns-sanketadlak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: error-handling-patterns
Source: https://github.com/SanketAdlak/PDMProjectDesign/tree/main/.agents/skills/error-handling-patterns
Command: npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill error-handling-patterns-sanketadlak

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Applications fail unpredictably when errors are handled inconsistently, swallowed silently, or allowed to cascade across services. This Skill provides proven patterns for exceptions, Result types, retries, circuit breakers, and graceful degradation so failures are caught, logged, and recovered from correctly. ## Core Features & Use Cases - Language-Specific Patterns: Custom exception hierarchies in Python, Result types and async error handling in TypeScript, Result/Option types in Rust, and explicit error returns with wrapping in Go. - Resilience Patterns: Circuit breaker implementation, retry with exponential backoff, error aggregation for batch validation, and fallback chains for graceful degradation. - Use Case: When building an API that calls external payment services, apply the circuit breaker pattern to stop cascading failures, wrap external errors with context, and fall back to cached data when the primary source fails. ## Quick Start Show me how to add retry logic with exponential backoff and a circuit breaker to my Python function that calls an external API.

Frequently Asked Questions about error-handling-patterns

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

FAQPage Schema
How do I implement retry with exponential backoff in Python?

Use a decorator that wraps the function, catches specified exceptions, and sleeps for backoff_factor raised to the attempt number between retries. After the maximum attempts are exhausted, it re-raises the last exception so callers can handle the failure.

When should I use Result types vs exceptions?

Use Result types for expected errors like validation failures where callers should explicitly handle outcomes. Use exceptions for unexpected, exceptional conditions. Result types make failure paths visible in function signatures, while exceptions suit truly exceptional control flow.

How does a circuit breaker prevent cascading failures?

A circuit breaker tracks failure counts and opens after a threshold, rejecting requests immediately instead of calling the failing service. After a timeout it enters half-open state to test recovery, closing again once enough successes occur.

How do I wrap and check errors in Go?

Wrap errors with fmt.Errorf using the %w verb to preserve the error chain. Use errors.Is to compare against sentinel errors and errors.As to extract custom error types like ValidationError from the wrapped chain.

What are common error handling mistakes to avoid?

Avoid catching overly broad exception types, empty catch blocks that swallow errors, logging and re-throwing which duplicates log entries, and forgetting to clean up resources. Use context managers, try-finally, or defer for cleanup.