π¦Master Rust Error Handling with Result, ? and thiserror
Stop reaching for unwrap() and panic!. Learn Rust's error-as-value model, then wield Result, ?, anyhow, and thiserror well enough to design a clean error hierarchy for a small CLI.
Phase 1Errors as Values, Not Exceptions
See errors as values, not runtime exceptions.
Rust has no exceptions β and that is the point
6 minRust has no exceptions β and that is the point
Option is a missing value β Result is a failed operation
5 minOption is a missing value β Result is a failed operation
panic! is for impossible β not for inconvenient
6 minpanic! is for impossible β not for inconvenient
Pattern-match until the ? operator earns its place
6 minPattern-match until the ? operator earns its place
Phase 2Propagating Errors with ? and Conversions
Convert unwrap and panic into Result with ?.
? is early-return plus a type coercion
6 min? is early-return plus a type coercion
Turn one error into another without losing the trail
6 minTurn one error into another without losing the trail
map, and_then, or_else β Result as a pipeline
6 minmap, and_then, or_else β Result as a pipeline
Your main function can return Result β and probably should
5 minYour main function can return Result β and probably should
Refactor one unwrap at a time β not all at once
6 minRefactor one unwrap at a time β not all at once
Phase 3Choosing anyhow, thiserror, or Custom Enums
Choose between anyhow, thiserror, and custom enums.
A scenario β anyhow or thiserror?
7 minA scenario β anyhow or thiserror?
Your CLI crashed at 3am β what does the log tell you?
7 minYour CLI crashed at 3am β what does the log tell you?
You're publishing a crate β design its errors like an API
7 minYou're publishing a crate β design its errors like an API
Your binary imports your own library β where do anyhow and thiserror meet?
7 minYour binary imports your own library β where do anyhow and thiserror meet?
Phase 4Designing a CLI Error Hierarchy
Design an error hierarchy for a real CLI.
Design and ship an error hierarchy for a small CLI
8 minDesign and ship an error hierarchy for a small CLI
Frequently asked questions
- Why doesn't Rust use try/catch like Java or Python?
- This is covered in the βMaster Rust Error Handling with Result, ? and thiserrorβ learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- When should I use anyhow versus thiserror?
- This is covered in the βMaster Rust Error Handling with Result, ? and thiserrorβ learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- What does the ? operator actually do under the hood?
- This is covered in the βMaster Rust Error Handling with Result, ? and thiserrorβ learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- How do I convert between different error types cleanly?
- This is covered in the βMaster Rust Error Handling with Result, ? and thiserrorβ learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
- Is it ever okay to use unwrap() in production code?
- This is covered in the βMaster Rust Error Handling with Result, ? and thiserrorβ learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
Related paths
πPython Decorators Introduction
Build one mental model for Python decorators that covers closures, argument passing, functools.wraps, and stacking β then ship a working caching or logging decorator from scratch in under 30 lines.
π¦Rust Lifetimes Explained
Stop reading `'a` as line noise and start reading it as scope arithmetic β one failing snippet at a time β until you can thread lifetimes through a small parser or iterator adapter without fighting the borrow checker.
βΈοΈKubernetes Core Concepts
Stop drowning in 30+ resource types. Build the mental model one primitive at a time -- pods, deployments, services, ingress, config -- then deploy a real app with rolling updates and health checks.
πBig O Intuition
Stop treating Big O as math you memorized for an interview β build the intuition to spot O(nΒ²) disasters, pick the right data structure without thinking, and rewrite a slow function from O(nΒ²) to O(n) in under five minutes.