handling-rust-errors

Official

Master Rust error handling, debug with ease.

Authorhashintel
Version1.0.0
Installs0

System Documentation

What problem does it solve?

This Skill provides HASH-specific patterns for robust and consistent error handling in Rust using the error-stack crate. It eliminates common pitfalls, ensures clear, debuggable error reports, and reduces the time spent on identifying the root cause of issues, allowing you to build more reliable software.

Core Features & Use Cases

  • Structured Error Types: Guides you to define custom error enums with derive_more for clear, user-friendly messages and structured data, improving error clarity.
  • Contextual Propagation: Learn to propagate errors with .change_context() for seamless type conversion and .attach() for adding rich debugging information, creating a comprehensive error trail.
  • Lazy Context Attachment: Utilize _with variants (attach_with, change_context_with) to defer expensive context computations until an error actually occurs, optimizing performance.
  • Error Documentation: Provides guidance on documenting error conditions in function signatures using # Errors sections and intra-doc links, enhancing API clarity.
  • Use Case: When a function might fail (e.g., a database operation), this skill guides you to wrap the external error with Report::new, convert it to a specific MyError variant using change_context, and attach relevant debugging details like an ID using attach, ensuring a clear error trail.

Quick Start

Use the handling-rust-errors skill to define a new error enum 'NetworkError' with variants for 'ConnectionFailed' and 'Timeout'.

Dependency Matrix

Required Modules

None required

Components

references

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: handling-rust-errors
Download link: https://github.com/hashintel/hash/archive/main.zip#handling-rust-errors

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository