m06-error-handling

Installation
Summary

Rust error handling strategy: when to use Result, Option, panic, and which error crate.

  • Distinguishes between expected failures (Result/Option), bugs (panic), and unrecoverable errors; includes decision flowchart and core questions to ask before choosing a strategy
  • Recommends thiserror for typed library errors and anyhow for ergonomic application-level error handling; covers error propagation with ? and context attachment
  • Provides quick reference for unwrap vs expect vs panic, library vs application patterns, and common anti-patterns like silent error ignoring or over-use of unwrap
SKILL.md

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
Related skills

More from zhanghandong/rust-skills

Installs
734
GitHub Stars
1.1K
First Seen
Jan 20, 2026