actionbook avatar

M06 Error Handling

This cuts through Rust's error handling by asking the right questions first: is this failure expected or a bug? Instead of defaulting to unwrap or panic, it walks you through Option versus Result, thiserror versus anyhow, and when propagation with ? actually makes sense. The flowchart alone is worth it. It connects to domain modeling (m09) when you're unsure whether absence is normal, and distinguishes library code (use thiserror for typed errors) from application code (use anyhow for ergonomics). The "trace up" and "trace down" structure helps when you're stuck between too many unwraps or lost error context. Good for anyone past the basics who keeps second-guessing their error strategy.

skills.sh installs
3.7K
GitHub stars
1.6K
last updated
Aug 21, 2026

Install

$ npx -y skills add actionbook/rust-skills --skill m06-error-handling --agent claude-code

Installs into .claude/skills of the current project.

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

PatternDon't Just SayAsk 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:

  1. What kind of failure is this?

    • Expected → Result<T, E>
    • Absence normal → Option
    • Bug/invariant → panic!
    • Unrecoverable → panic!
  2. Who handles this?

    • Caller → propagate with ?
    • Current function → match/if-let
    • User → friendly error message
    • Programmer → panic with message
  3. What context is needed?

    • Type of error → thiserror variants
    • Call chain → anyhow::Context
    • Debug info → anyhow or tracing

Sponsors

Details

Repository
github.com/actionbook/rust-skills
Categories
Debugging, Rust
First seen
May 16, 2026

More from actionbook/rust-skills

All 38

Recommended

More Debugging
1copilotkit avatarcopilotkit-debugcopilotkit/copilotkitUse when diagnosing CopilotKit issues -- runtime connectivity failures, agent not responding, streaming errors, tool execution problems, transcription failures,2.8Kskills.sh installs
2cursor avatarfix-cicursor/pluginsFind failing PR checks, inspect logs or external check links, and apply focused fixes2.5Kskills.sh installs
3owl-listener avatarerror-handling-uxowl-listener/designer-skillsDesign error prevention, detection, and recovery experiences.2.4Kskills.sh installs
4nvidia avataromniverse-usd-performance-tuningnvidia/skillsTop-level workflow skill for USD performance diagnosis and optimization. Handles slow loading, high memory, low FPS, and broad scene-optimization requests; dele2.3Kskills.sh installs
5p4nda0s avatarrev-unicorn-debugp4nda0s/reverse-skillsDebug and emulate specific code fragments or functions using the Unicorn engine. Activate when the user wants to emulate a function with Unicorn, trace binary e1.9Kskills.sh installs
6github avatarcreating-oracle-to-postgres-migration-bug-reportgithub/awesome-copilotCreates structured bug reports for defects found during Oracle-to-PostgreSQL migration. Use when documenting behavioral differences between Oracle and PostgreSQ1.8Kskills.sh installs