
M06 Error Handling
Decision guide for Rust error handling: choosing Result, Option, panic, thiserror, or anyhow.
- skills.sh installs
- 3.8K
- GitHub stars
- 1.6K
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers when to use Result, Option,
?propagation, unwrap/expect, and panic, plus the library-versus-application crate choice - Includes a decision flowchart, a quick-reference table, common errors with fixes, and anti-patterns to avoid
- Enforces the question "Is this failure expected or a bug?" before picking a strategy, and points to
thiserrorfor libraries andanyhowfor applications - Designed for Rust developers designing error types and propagation, with links to related domain and ecosystem skills
Install
$ npx -y skills add actionbook/rust-skills --skill m06-error-handling -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Error Handling
Layer 1: Language Mechanics
Core Question
Is this failure expected or a bug?
Before choosing error handling strategy:
- Can this fail in normal operation?
- Who should handle this failure?
- What context does the caller need?
Error → Design Question
| Pattern | Don't Just Say | Ask Instead |
|---|---|---|
| unwrap panics | "Use ?" | Is None/Err actually possible here? |
| Type mismatch on ? | "Use anyhow" | Are error types designed correctly? |
| Lost error context | "Add .context()" | What does the caller need to know? |
| Too many error variants | "Use Box" | Is error granularity right? |
Thinking Prompt
Before handling an error:
-
What kind of failure is this?
- Expected → Result<T, E>
- Absence normal → Option
- Bug/invariant → panic!
- Unrecoverable → panic!
-
Who handles this?
- Caller → propagate with ?
- Current function → match/if-let
- User → friendly error message
- Programmer → panic with message
-
What context is needed?
- Type of error → thiserror variants
- Call chain → anyhow::Context
- Debug info → anyhow or tracing
Details
- Repository
- github.com/actionbook/rust-skills
- Category
- Rust
- First seen
- May 16, 2026
More from actionbook/rust-skills
All 38- M01 Ownership3.7K
- M05 Type Driven3.7K
- M04 Zero Cost3.7K
- M02 Resource3.7K
- Rust Refactor Helper3.7K
- M03 Mutability3.7K
- M12 Lifecycle3.6K
- M09 Domain3.6K
- M14 Mental Model3.6K
- M13 Domain Error3.6K
- M11 Ecosystem3.6K
- Unsafe Checker3.6K
- Rust Code Navigator3.6K
- Rust Trait Explorer3.5K
- Rust Call Graph3.5K
- Rust Symbol Analyzer3.5K
- Domain Web3.5K
- Domain Cli3.5K
- Rust Learner3.4K
- Rust Skill Creator3.4K
- Rust Deps Visualizer3.3K
- Meta Cognition Parallel3.3K
- Rust Daily3.3K
- Domain Embedded3.2K
Similar to M06 Error Handling
More Rust
m13-domain-erroractionbook/rust-skills3.6K installsLayered error-handling guide that sorts errors by audience and recovery path, with Rust examples.
error-handling-patternswshobson/agents23.9K installsCross-language error handling guide covering exceptions, Result types, propagation, and graceful degradation for resilient applications.
rust-best-practicesapollographql/skills23.4K installsIdiomatic Rust guidance covering ownership, error handling, performance, linting, testing, and documentation, drawn from Apollo's handbook.
rust-patternsaffaan-m/ecc6.7K installsIdiomatic Rust patterns for ownership, error handling, enums, traits, iterators, and concurrency in production code.
m11-ecosystemactionbook/rust-skills3.6K installsStructured guide for choosing and integrating Rust crates, covering language interop, Cargo features, and common crate errors.