Validate Implementation: Ensure resources are cleaned up (try-finally) and context is preserved.
Instructions
Language-Specific Patterns
Python
Use custom exception hierarchies for domain errors.
Implement retries with exponential backoff for network operations.
Use context managers (@contextmanager) for resource cleanup.
TypeScript/JavaScript
Use custom classes extending Error for typed errors.
Use the Result Type Pattern ({ ok: true, value: T } | { ok: false, error: E }) for explicit handling.
Always handle async errors (try-catch in async/await).
Go/Rust
Follow idiomatic patterns (explicit error returns in Go, Result/Option in Rust).
Universal Patterns
Circuit Breaker: Prevent cascading failures.
Error Aggregation: Collect multiple errors before failing.
Graceful Degradation: Provide fallbacks for non-critical failures.
Resources
references/exception-hierarchy-design.md
references/error-recovery-strategies.md
references/async-error-handling.md
1---2name: error-handling-patterns3description: Error Handling Patterns4---56# Error Handling Patterns78Build resilient applications with robust error handling strategies that gracefully handle failures and provide excellent debugging experiences.910## When to use this skill11- Implementing error handling in new features.12- Designing error-resilient APIs.13- Debugging production issues.14- Improving application reliability.15- Creating better error messages for users and developers.16- Implementing retry and circuit breaker patterns.1718## Workflow191. **Identify Error Category**: Determine if the error is recoverable (timeouts, invalid input) or unrecoverable (OOM, bugs).202. **Select Philosophy**: Choose between Exceptions, Result Types, or Error Codes based on the language and context.213. **Apply Patterns**: Implement the appropriate pattern (Circuit Breaker, Aggregation, Graceful Degradation).224. **Validate Implementation**: Ensure resources are cleaned up (try-finally) and context is preserved.2324## Instructions2526### Language-Specific Patterns2728#### Python29- Use custom exception hierarchies for domain errors.30- Implement retries with exponential backoff for network operations.31- Use context managers (`@contextmanager`) for resource cleanup.3233#### TypeScript/JavaScript34- Use custom classes extending `Error` for typed errors.35- Use the **Result Type Pattern** (`{ ok: true, value: T } | { ok: false, error: E }`) for explicit handling.36- Always handle async errors (try-catch in async/await).3738#### Go/Rust39- Follow idiomatic patterns (explicit error returns in Go, `Result`/`Option` in Rust).4041### Universal Patterns42- **Circuit Breaker**: Prevent cascading failures.43- **Error Aggregation**: Collect multiple errors before failing.44- **Graceful Degradation**: Provide fallbacks for non-critical failures.4546## Resources47- `references/exception-hierarchy-design.md`48- `references/error-recovery-strategies.md`49- `references/async-error-handling.md`
Run npx skillmds@latest add alunadev/error-handling-patterns in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Error Handling Patterns It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. Capability flags: docs only. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
alunadev (@alunadev) published this skill. Their other Agent Skills are listed on their SkillMD profile.