Guides design of domain error handling: error categorization, recovery strategies, retries, fallbacks and error hierarchies.
- What it does
- This skill provides design guidance for domain error handling, centered on the question of who must handle an error and how they should recover. It offers an error categorization table (user-facing, internal, system, transient, permanent), thinking prompts, recovery patterns such as retry with backoff, fallback, circuit breaker, timeout and bulkhead, plus a sample Rust error hierarchy and retry code. It also lists common mistakes and anti-patterns and points to related skills for implementation details.
- When to use it
- Use it when designing error types and recovery behavior for a domain or service, especially when deciding what is user-facing versus internal, what is retryable, and what context to attach. It is also useful for reviewing existing error handling for anti-patterns such as string errors, infinite retries or exposing internal errors.
- Requirements
- No scripts or assets ship with the skill; it is instructions only. The examples reference Rust crates such as thiserror, anyhow, tokio-retry, backoff and failsafe-rs, but nothing needs to be installed to read the guidance.
Domain Error Strategy
Layer 2: Design Choices
Core Question
Who needs to handle this error, and how should they recover?
Before designing error types:
- Is this user-facing or internal?
- Is recovery possible?
- What context is needed for debugging?
Error Categorization
Thinking Prompt
Before designing error types:
-
Who sees this error?
- End user → friendly message, actionable
- Developer → detailed, debuggable
- Ops → structured, alertable
-
Can we recover?
- Transient → retry with backoff
- Degradable → fallback value
- Permanent → fail fast, alert
-
What context is needed?
- Call chain → anyhow::Context
- Request ID → structured logging
- Input data → error payload
Trace Up ↑
To domain constraints (Layer 3):
Trace Down ↓
To implementation (Layer 1):
Quick Reference
Error Hierarchy
Retry Pattern
Common Mistakes
Anti-Patterns
Related Skills