Smithery Logo
MCPsSkillsDocsPricing
Login
Smithery Logo

Accelerating the Agent Economy

Resources

DocumentationPrivacy PolicySystem Status

Company

PricingAboutBlog

Connect

© 2026 Smithery. All rights reserved.

    roelofvheeren

    handling-errors

    roelofvheeren/handling-errors
    Coding

    About

    SKILL.md

    Install

    Install via Skills CLI

    or add to your agent
    • Claude Code
      Claude Code
    • Codex
      Codex
    • OpenClaw
      OpenClaw
    • Cursor
      Cursor
    • Amp
      Amp
    • GitHub Copilot
      GitHub Copilot
    • Gemini CLI
      Gemini CLI
    • Kilo Code
      Kilo Code
    • Junie
      Junie
    • Replit
      Replit
    • Windsurf
      Windsurf
    • Cline
      Cline
    • Continue
      Continue
    • OpenCode
      OpenCode
    • OpenHands
      OpenHands
    • Roo Code
      Roo Code
    • Augment
      Augment
    • Goose
      Goose
    • Trae
      Trae
    • Zencoder
      Zencoder
    • Antigravity
      Antigravity
    ├─
    ├─
    └─

    About

    Provides robust error handling strategies and patterns. Use when the user mentions resilience, error handling, fallbacks, or debugging failures.

    SKILL.md

    Handling Errors

    When to use this skill

    • Implementing error handling in new features.
    • Designing error-resilient APIs and distributed systems.
    • Improving application reliability through Circuit Breakers or Graceful Degradation.
    • Standardizing error messages and custom exception hierarchies.

    Workflow

    1. Categorization
      • Determine if the error is Recoverable (e.g., Network Timeout) or Unrecoverable (e.g., OOM).
    2. Strategy Selection
      • Choose a pattern: Fail Fast, Retry, Circuit Breaker, or Graceful Degradation.
    3. Implementation
      • Use language-specific best practices (Custom Exceptions, Result Types, or Explicit Returns).
    4. Verification
      • Validate that errors are logged with context and resources are cleaned up.

    Universal Patterns

    Circuit Breaker

    Prevent cascading failures by rejecting requests when a service is failing.

    # Logic: CLOSED -> failure threshold reached -> OPEN (wait timeout) -> HALF_OPEN (test)
    

    Error Aggregation

    Collect multiple errors (e.g., during validation) instead of failing on the first one.

    class ErrorCollector {
      private errors: Error[] = [];
      add(error: Error) { this.errors.push(error); }
      throw() { if (this.errors.length) throw new AggregateError(this.errors); }
    }
    

    Graceful Degradation

    Provide fallback functionality (e.g., fetch from cache if DB is down).

    def with_fallback(primary, fallback):
        try: return primary()
        except Exception: return fallback()
    

    Language-Specific Patterns

    Python

    • Hierarchy: Use ApplicationError(Exception) as a base.
    • Cleanup: Use @contextmanager or try/finally.
    • Retry: Implement decorators with exponential backoff.

    TypeScript/JS

    • Results: Use type Result<T, E> = { ok: true; value: T } | { ok: false; error: E }.
    • Async: Handle Promise rejections explicitly; avoid swallowing errors in catch.

    Rust/Go

    • Rust: Prefer Result<T, E> and the ? operator.
    • Go: Check if err != nil explicitly; use fmt.Errorf("...: %w", err) for wrapping.

    Best Practices

    • Fail Fast: Validate early.
    • Preserve Context: Log metadata, stack traces, and timestamps.
    • Don't Swallow Errors: Log or re-throw; empty catch blocks are forbidden.
    • Cleanup: Always close files and connections.

    Resources

    • retry-patterns.md
    • custom-errors.ts
    Recommended Servers
    Vercel Grep
    Vercel Grep
    Sentry
    Sentry
    Cloudflare Workers Observability
    Cloudflare Workers Observability
    Repository
    roelofvheeren/elvison-os
    Files