error-handling

Implement layered exception handling with retry logic and exponential backoff.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the challenge of managing errors and exceptions effectively across different layers of an application, ensuring resilience and maintainability.

Core Features & Use Cases

  • Layered Exception Handling: Defines distinct responsibilities for handling errors in infrastructure, service, and API/CLI layers.
  • Exception Mapping: Translates low-level exceptions into domain-specific errors at layer boundaries.
  • Retry Mechanisms: Implements safe retry logic with exponential backoff for transient failures.
  • Logging Best Practices: Guides on correct exception logging to preserve tracebacks.
  • Graceful Degradation: Provides strategies for maintaining functionality when services fail.
  • Use Case: When building a web service, use this Skill to ensure that database connection errors are caught by the repository layer, translated into a ServiceUnavailable domain error, and then mapped to a 503 HTTP response by the API layer, all while logging the original error with its traceback.

Quick Start

Use the error-handling skill to implement a retry mechanism with exponential backoff for a function that calls an external API.

Frequently Asked Questions about error-handling

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

FAQPage Schema
How do I handle exceptions across different application layers?

Layered exception handling assigns distinct responsibilities for managing errors across infrastructure, service, and API/CLI layers. This approach translates low-level exceptions into domain-specific errors at layer boundaries to ensure resilience and maintainability throughout the application architecture.

What is the best way to implement retry logic for transient failures?

Implementing safe retry logic requires using an exponential backoff pattern for transient failures. This strategy ensures graceful degradation and maintains functionality when external services or infrastructure components temporarily fail, preventing cascading application crashes.

How does exception mapping work at service layer boundaries?

Exception mapping translates low-level infrastructure exceptions into domain-specific errors at layer boundaries. For example, a database connection error caught by the repository layer becomes a ServiceUnavailable domain error, which the API layer then maps to a 503 HTTP response.

What are common error handling anti-patterns I should avoid?

Common error handling anti-patterns include failing to preserve tracebacks during logging and skipping exception translation at layer boundaries. Addressing these ensures robust error management by maintaining clear exception context and achieving graceful degradation across application layers.

Can I use this approach for both web services and CLI applications?

Yes, this error handling strategy defines distinct responsibilities for both API and CLI layers. It ensures robust error management by translating domain errors into appropriate API HTTP responses or CLI exit codes while logging the original error with its traceback.

Why does my application lose the original traceback when logging exceptions?

Logging exceptions incorrectly often causes the original traceback to be lost. Following correct logging best practices preserves tracebacks by capturing the original error context before translating it into domain-specific errors at application layer boundaries.