m06-error-handling

Design Rust error handling with thiserror, anyhow, and context propagation.

Updated Jan 29, 2026
One-click install
npx skills add https://github.com/CallMeLuigiv2/Socratic-IDE --skill m06-error-handling-callmeluigiv2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: m06-error-handling
Source: https://github.com/CallMeLuigiv2/Socratic-IDE/tree/main/.agents/skills/m06-error-handling
Command: npx skills add https://github.com/CallMeLuigiv2/Socratic-IDE --skill m06-error-handling-callmeluigiv2

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill guides developers in designing robust error handling in Rust projects, covering when to use Result, Option, panic, and how to propagate errors with context across library and application boundaries.

Core Features & Use Cases

  • Structured decision framework for error strategies (unwrap vs. context, thiserror vs. anyhow)
  • Practical patterns for Result, Option, and error chaining
  • Library vs. application guidance with examples and testing patterns

Quick Start

Ask an AI to design error-handling for a Rust function, illustrating proper error propagation, context, and conversion between error types without losing information.

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 Rust error propagation across library and application boundaries?

Rust error propagation requires distinct strategies for library versus application boundaries. Libraries should define typed errors with thiserror, while applications use anyhow for context-rich messages, ensuring errors are propagated without losing information.

When should I use thiserror vs anyhow for Rust error handling?

Choose thiserror versus anyhow based on your project boundary. Use thiserror in libraries to define specific typed errors, and use anyhow in applications for flexible context-rich error handling and simplified error chaining.

What is the best way to add context to Rust Result error types?

The best way to add context to Rust Result error types is using anyhow during application-level error propagation. This preserves the original error while attaching context-rich messages, preventing information loss across function boundaries.

How do I design Rust panic strategies and decide between unwrap and Result?

Designing Rust panic strategies involves choosing unwrap for unrecoverable contract violations and Result for expected recoverable failures. The structured decision framework evaluates whether a failure is truly unexpected before triggering a panic.

How do I test Rust error handling patterns and typed error conversions?

Testing Rust error handling patterns involves asserting that typed errors convert correctly across boundaries. Validate that Result returns propagate expected variants and that context enhancement via anyhow preserves the original error chain.

Why does my Rust library lose error context when returning generic Result types?

Rust libraries lose error context when returning generic Result types if they discard the original error source. Define typed errors using thiserror and implement the source trait to maintain the full error chaining context.