Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
actionbook avatar

M06 Error Handling

  • 1.5k installs
  • 1.3k repo stars
  • Updated May 24, 2026
  • actionbook/rust-skills

m06-error-handling is a Rust skill for Result, Option, anyhow, thiserror, and panic versus return guidance.

About

The m06-error-handling skill guides Rust error handling design choices mapping goals to Result and Option propagation, custom error types, anyhow and thiserror usage, and when panic is acceptable versus returning errors. It triggers on Result, unwrap, expect, error propagation, and custom error keywords with user-invocable false for automatic routing. Use when developers decide error types, propagation with the question mark operator, and panic boundaries in Rust services and libraries.

  • Result and Option propagation patterns with ? operator guidance.
  • anyhow versus thiserror selection for applications versus libraries.
  • When to panic versus return Result decision prompts.
  • Custom error type design for domain failures.
  • Triggered by error handling and panic keyword phrases.

M06 Error Handling by the numbers

  • 1,486 all-time installs (skills.sh)
  • +52 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Ranked #8 of 129 Rust skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

m06-error-handling capabilities & compatibility

Capabilities
result and option propagation guidance · anyhow and thiserror crate selection · custom error type patterns · panic versus return decision framework
Use cases
debugging · refactoring
From the docs

What m06-error-handling says it does

CRITICAL: Use for error handling.
SKILL.md
npx skills add https://github.com/actionbook/rust-skills --skill m06-error-handling

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1.5k
repo stars1.3k
Security audit3 / 3 scanners passed
Last updatedMay 24, 2026
Repositoryactionbook/rust-skills

How should I handle errors in Rust with Result, custom errors, and when is panic acceptable?

Apply Rust error handling patterns with Result, Option, anyhow, thiserror, and panic versus return decisions.

Who is it for?

Rust developers choosing error crates and propagation patterns in services or libraries.

Skip if: Skip for non-Rust languages or performance tuning without error design questions.

When should I use this skill?

User asks about Rust Result, anyhow, thiserror, unwrap, expect, or error propagation.

What you get

Error handling design using appropriate Result types, propagation, and panic boundaries.

  • typed error enum
  • library error module

By the numbers

  • Lists 5 library error design principles in the actionbook module
  • Worked example covers 2 DatabaseError variants: ConnectionFailed and QueryFailed

Files

SKILL.mdMarkdownGitHub ↗

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<dyn Error>"Is error granularity right?

---

Thinking Prompt

Before handling an error:

1. What kind of failure is this?

  • Expected → Result<T, E>
  • Absence normal → Option<T>
  • 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

---

Trace Up ↑

When error strategy is unclear:

"Should I return Result or Option?"
    ↑ Ask: Is absence/failure normal or exceptional?
    ↑ Check: m09-domain (what does domain say?)
    ↑ Check: domain-* (error handling requirements)
SituationTrace ToQuestion
Too many unwrapsm09-domainIs the data model right?
Error context designm13-domain-errorWhat recovery is needed?
Library vs app errorsm11-ecosystemWho are the consumers?

---

Trace Down ↓

From design to implementation:

"Expected failure, library code"
    ↓ Use: thiserror for typed errors

"Expected failure, application code"
    ↓ Use: anyhow for ergonomic errors

"Absence is normal (find, get, lookup)"
    ↓ Use: Option<T>

"Bug or invariant violation"
    ↓ Use: panic!, assert!, unreachable!

"Need to propagate with context"
    ↓ Use: .context("what was happening")

---

Quick Reference

PatternWhenExample
Result<T, E>Recoverable errorfn read() -> Result<String, io::Error>
Option<T>Absence is normalfn find() -> Option<&Item>
?Propagate errorlet data = file.read()?;
unwrap()Dev/test onlyconfig.get("key").unwrap()
expect()Invariant holdsenv.get("HOME").expect("HOME set")
panic!Unrecoverablepanic!("critical failure")

Library vs Application

ContextError CrateWhy
LibrarythiserrorTyped errors for consumers
ApplicationanyhowErgonomic error handling
MixedBoththiserror at boundaries, anyhow internally

Decision Flowchart

Is failure expected?
├─ Yes → Is absence the only "failure"?
│        ├─ Yes → Option<T>
│        └─ No → Result<T, E>
│                 ├─ Library → thiserror
│                 └─ Application → anyhow
└─ No → Is it a bug?
        ├─ Yes → panic!, assert!
        └─ No → Consider if really unrecoverable

Use ? → Need context?
├─ Yes → .context("message")
└─ No → Plain ?

---

Common Errors

ErrorCauseFix
unwrap() panicUnhandled None/ErrUse ? or match
Type mismatchDifferent error typesUse anyhow or From
Lost context? without contextAdd .context()
cannot use ?Missing Result returnReturn Result<(), E>

---

Anti-Patterns

Anti-PatternWhy BadBetter
.unwrap() everywherePanics in production.expect("reason") or ?
Ignore errors silentlyBugs hiddenHandle or propagate
panic! for expected errorsBad UX, no recoveryResult
Box<dyn Error> everywhereLost type infothiserror

---

Related Skills

WhenSee
Domain error strategym13-domain-error
Crate boundariesm11-ecosystem
Type-safe errorsm05-type-driven
Mental modelsm14-mental-model

Related skills

Forks & variants (1)

M06 Error Handling has 1 known copy in the catalog totaling 840 installs. They canonicalize to this original listing.

How it compares

Pick m06-error-handling over generic Rust snippets when crate API stability and error matching matter more than fastest prototyping with anyhow.

FAQ

What does m06-error-handling cover?

Rust Result and Option patterns, anyhow and thiserror usage, custom errors, and panic versus return decisions.

When should I use m06-error-handling?

When designing or reviewing Rust error handling, propagation, and panic boundaries.

Is m06-error-handling safe to install?

Review the Security Audits panel on this page before installing in production.

Rustbackendtesting

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.