HASH error handling patterns using error-stack crate. Use when working with Result types, Report types, defining custom errors, propagating errors with change_context, adding context with attach, implementing Error trait, or documenting error conditions in Rust code.
71
89%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
The canonical home for this skill is handling-rust-errors in hashintel/hash
HASH-specific error handling patterns using the error-stack crate for consistent, debuggable error handling across the Rust codebase.
HASH uses error-stack exclusively for error handling:
✅ DO:
Report<MyError> for all error typesReport<MyError>Error from core::error:: (not std::error::)ResultExt as _ for trait methods❌ DON'T:
anyhow or eyre cratesBox<dyn Error> (except in tests/prototyping)Report<Box<dyn Error>>thiserror (use derive_more instead)HashQL compiler code uses a different error handling approach.
Code in libs/@local/hashql/* uses the hashql-diagnostics crate instead of error-stack. This is because compiler errors require rich formatting capabilities:
Which approach to use:
| Location | Error Handling |
|---|---|
libs/@local/hashql/* (compiler code) | Use hashql-diagnostics → See writing-hashql-diagnostics skill |
| Everywhere else | Use error-stack patterns from this skill |
Traditional error-stack patterns still apply for HashQL infrastructure code (CLI, file I/O, configuration) that doesn't involve compiler diagnostics.
Choose the reference that matches your current task:
Use when: Creating new error types or error enums
derive_moreError traitUse when: Handling Result types, using ? operator
.change_context() and .change_context_with().attach() and .attach_with()Use when: Writing doc comments for fallible functions
# Errors section formatuse error_stack::Report;
return Err(Report::new(MyError::NotFound))
.attach(format!("ID: {}", id));use error_stack::ResultExt as _;
some_result
.change_context(MyError::OperationFailed)
.attach("Additional context")?;use error_stack::ResultExt as _;
expensive_operation()
.change_context(MyError::OperationFailed)
.attach_with(|| format!("Debug info: {:?}", expensive_computation()))?;Result types, using ? operator757cae9
Canonical home
since Jul 28, 2026
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.