handling-rust-errors

Standardize Rust error handling with error-stack, derive_more, and change_context.

Updated Jan 28, 2026
One-click install
npx skills add https://github.com/aRustyDev/git-atomic --skill handling-rust-errors-arustydev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: handling-rust-errors
Source: https://github.com/aRustyDev/git-atomic/tree/main/.claude/skills/lang-rust-errors-dev
Command: npx skills add https://github.com/aRustyDev/git-atomic --skill handling-rust-errors-arustydev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

HASH error handling patterns in Rust enable a consistent, testable approach to create, propagate, and document errors across a codebase using the error-stack crate and derive_more.

Core Features & Use Cases

  • Define error types with derive_more and implement the Error trait for consistent formatting
  • Propagate errors with change_context, attach, and ResultExt across sync and async boundaries
  • Document error variants and usage with intra-doc links and examples
  • Apply HASH patterns in real projects to improve debuggability and maintainability

Quick Start

Define a small error enum using derive_more and implement the Error trait. In a sample function, wrap an upstream error with change_context and augment it with attach for extra context.

Frequently Asked Questions about handling-rust-errors

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

FAQPage Schema
How do I standardize Rust error handling across a codebase?▼

Standardize Rust error handling by applying the error-stack pattern to unify error creation and propagation. This approach uses derive_more to define error types and implement the Error trait for consistent formatting across library boundaries.

What's the best way to propagate Rust errors across async boundaries?▼

Propagate Rust errors across async boundaries using error-stack's change_context and ResultExt. These tools maintain consistent error context and stack traces seamlessly when propagating through asynchronous functions and library boundaries.

How do I add contextual information to Rust errors?▼

Add contextual information to Rust errors using error-stack's attach method. This augments wrapped upstream errors with extra context during propagation, improving debuggability and maintainability throughout the codebase.

How does derive_more work with error-stack for error type definitions?▼

derive_more works with error-stack by generating the Error trait implementation for small error enums. This ensures consistent error formatting while allowing change_context to handle type conversions during error propagation.

Can I document Rust error variants using the error-stack pattern?▼

Yes, you can document Rust error variants using the error-stack pattern. The approach incorporates intra-doc links and examples directly within error type definitions to clearly document usage and error conditions.

Why should I use change_context instead of standard error conversion in Rust?▼

Use change_context instead of standard error conversion in Rust because it preserves the original error stack while wrapping it in a new error type. This maintains debuggability across library boundaries better than simple From implementations.