handling-rust-errors
OfficialMaster 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_morefor 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
_withvariants (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
# Errorssections 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 specificMyErrorvariant usingchange_context, and attach relevant debugging details like anIDusingattach, 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 requiredComponents
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.