Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
wshobson avatar

Error Handling Patterns

  • 18.5k installs
  • 38.3k repo stars
  • Updated July 22, 2026
  • wshobson/agents

Error Handling Patterns is a skill teaching error handling strategies including exceptions, Result types, recovery patterns, and meaningful error messages.

About

Master error handling patterns across languages including exceptions, Result types, error propagation, and graceful degradation. Covers error categories (recoverable vs unrecoverable), best practices for failing fast, preserving context, meaningful messages, and type-safe errors. Teaches when to use exceptions vs Result types, clean resource handling, and common pitfalls like catching too broadly or poor error messages.

  • Exception vs Result types: choose based on error recoverability
  • Graceful degradation and circuit breaker patterns
  • Comprehensive logging with context preservation

Error Handling Patterns by the numbers

  • 18,504 all-time installs (skills.sh)
  • +409 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Ranked #19 of 1,382 Code Review & Quality skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

error-handling-patterns capabilities & compatibility

Capabilities
error handling · testing · debugging · resilience · logging
Use cases
api development · debugging · testing
npx skills add https://github.com/wshobson/agents --skill error-handling-patterns

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs18.5k
repo stars38.3k
Security audit3 / 3 scanners passed
Last updatedJuly 22, 2026
Repositorywshobson/agents

How do you implement consistent error handling across services?

Implement production-grade error handling with appropriate patterns, meaningful debugging context, and resilient failure modes across distributed systems.

Who is it for?

Developers building APIs, microservices, and distributed systems; teams improving application reliability

Skip if: Simple scripts without error handling requirements

When should I use this skill?

A user implements error handling, designs APIs, debugs production failures, or asks to improve application reliability and error messages.

What you get

Resilient error types, propagation rules, graceful degradation paths, and actionable error messages in application code

  • Robust error handling code
  • Typed error definitions
  • Circuit breaker patterns

By the numbers

  • Covers 2 error handling philosophies
  • 2 error categories: recoverable and unrecoverable

Files

SKILL.mdMarkdownGitHub ↗

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 errors, exceptional conditions
  • Result Types: Expected errors, validation failures
  • Panics/Crashes: Unrecoverable errors, programming bugs

2. Error Categories

Recoverable Errors:

  • Network timeouts
  • Missing files
  • Invalid user input
  • API rate limits

Unrecoverable Errors:

  • Out of memory
  • Stack overflow
  • Programming bugs (null pointer, etc.)

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Best Practices

1. Fail Fast: Validate input early, fail quickly 2. Preserve Context: Include stack traces, metadata, timestamps 3. Meaningful Messages: Explain what happened and how to fix it 4. Log Appropriately: Error = log, expected failure = don't spam logs 5. Handle at Right Level: Catch where you can meaningfully handle 6. Clean Up Resources: Use try-finally, context managers, defer 7. Don't Swallow Errors: Log or re-throw, don't silently ignore 8. Type-Safe Errors: Use typed errors when possible

# Good error handling example
def process_order(order_id: str) -> Order:
    """Process order with comprehensive error handling."""
    try:
        # Validate input
        if not order_id:
            raise ValidationError("Order ID is required")

        # Fetch order
        order = db.get_order(order_id)
        if not order:
            raise NotFoundError("Order", order_id)

        # Process payment
        try:
            payment_result = payment_service.charge(order.total)
        except PaymentServiceError as e:
            # Log and wrap external service error
            logger.error(f"Payment failed for order {order_id}: {e}")
            raise ExternalServiceError(
                f"Payment processing failed",
                service="payment_service",
                details={"order_id": order_id, "amount": order.total}
            ) from e

        # Update order
        order.status = "completed"
        order.payment_id = payment_result.id
        db.save(order)

        return order

    except ApplicationError:
        # Re-raise known application errors
        raise
    except Exception as e:
        # Log unexpected errors
        logger.exception(f"Unexpected error processing order {order_id}")
        raise ApplicationError(
            "Order processing failed",
            code="INTERNAL_ERROR"
        ) from e

Common Pitfalls

  • Catching Too Broadly: except Exception hides bugs
  • Empty Catch Blocks: Silently swallowing errors
  • Logging and Re-throwing: Creates duplicate log entries
  • Not Cleaning Up: Forgetting to close files, connections
  • Poor Error Messages: "Error occurred" is not helpful
  • Returning Error Codes: Use exceptions or Result types
  • Ignoring Async Errors: Unhandled promise rejections

Related skills

How it compares

Use error-handling-patterns for in-code failure design; pair with observability or monitoring skills when the goal is production incident detection rather than error semantics.

FAQ

Should I use exceptions or Result types?

Use exceptions for unexpected/exceptional conditions; use Result types for expected errors, validation failures, and API-level error handling.

How should I log errors?

Error = log with stack trace and metadata; expected failure = don't spam logs. Use parameterized logging and preserve context including timestamps.

Is Error Handling Patterns safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Code Review & Qualitybackendtestingdevops

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.