m06-error-handling

Design typed Rust errors with thiserror and propagate them using anyhow.

3|Updated Mar 22, 2026
One-click install
npx skills add https://github.com/0xharryriddle/codex-field-kit --skill m06-error-handling-0xharryriddle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: m06-error-handling
Source: https://github.com/0xharryriddle/codex-field-kit/tree/main/archive/upstream/chasebuild-agent-skills/rust/skills/m06-error-handling
Command: npx skills add https://github.com/0xharryriddle/codex-field-kit --skill m06-error-handling-0xharryriddle

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rust error handling can be inconsistent and verbose; this Skill guides designing, propagating, and surfacing errors to keep code reliable and maintainable.

Core Features & Use Cases

  • Provide typed error definitions (thiserror) and standardize error reporting
  • Show ergonomic error handling at boundaries with anyhow and Context
  • Illustrate decision points between returning Result, Option, or panicking in practical scenarios

Quick Start

Create a small Rust project that defines a library error type using thiserror, propagates errors with anyhow and Context, and demonstrates converting between error kinds in a simple app.

Frequently Asked Questions about m06-error-handling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle errors in Rust using thiserror and anyhow?

Rust error handling with thiserror and anyhow involves defining typed errors for libraries and applying ergonomic context at boundaries. This Skill guides standardizing error types, enriching propagation with contextual messages, and converting between Result and Option safely.

When should I use Result, Option, or panic in Rust applications?

Choosing between Result, Option, and panic in Rust depends on recoverability. This Skill illustrates practical decision points for returning Result for expected failures, Option for absent values, and panicking for unrecoverable states.

What is the best way to propagate errors in Rust with context?

Propagating errors in Rust with context uses anyhow to wrap failures with descriptive messages. This Skill demonstrates clear error propagation, adding contextual information at application boundaries to keep code reliable and maintainable.

Does this Rust error handling approach work for both libraries and applications?

Yes, this Rust error handling approach applies to both library and application code. It covers typed error design using thiserror for public APIs and ergonomic contexts using anyhow for internal application boundaries.

Why does Rust error handling become inconsistent and verbose in real projects?

Rust error handling becomes verbose when error types lack standardization and context. This Skill solves inconsistent propagation by providing typed definitions with thiserror and standardized reporting using anyhow and Context.

How do I define a custom error type in Rust for robust code?

Defining a custom error type in Rust uses thiserror to create typed, standard error enumerations. This Skill shows how to design these types and transition between error kinds to turn Rust errors into robust, safe code.