Expand description
Compatibility and interoperability with other error handling libraries.
§Overview
This module provides integration with popular error handling libraries in the Rust ecosystem, enabling seamless interoperability and gradual migration paths. Each submodule offers bidirectional conversion traits and utilities for working with rootcause alongside other error handling approaches.
§Available Integrations
anyhow1- Integration with theanyhow1.x error handling library (requires thecompat-anyhow1feature flag)boxed_error- Convert reports to and from boxed error trait objects (Box<dyn Error>andBox<dyn Error + Send + Sync>)error_stack05- Integration with theerror-stack0.5.x error handling library (requires thecompat-error-stack05feature flag)error_stack06- Integration with theerror-stack0.6.x error handling library (requires thecompat-error-stack06feature flag)eyre06- Integration with theeyre0.6.x error handling library (requires thecompat-eyre06feature flag)
§When to Use Compatibility Modules
These compatibility modules are useful when:
- Migrating incrementally: Gradually adopt rootcause in an existing codebase without rewriting everything at once
- Interoperating with dependencies: Call libraries that use different error handling approaches from your rootcause-based code
- Mixed codebases: Work in projects where different parts use different error handling strategies
- Evaluating rootcause: Try out rootcause features while maintaining compatibility with your existing error handling
§Design Philosophy
Each compatibility module aims to provide:
- Bidirectional conversions: Convert errors in both directions to support flexible integration patterns
- Information preservation: Maintain error context and formatting across conversions where possible
- Ergonomic APIs: Use familiar Rust patterns like
From/Intotraits and extension traits with descriptive method names
§Example
Here’s how to use the IntoRootcause trait to convert external errors:
use rootcause::prelude::*;
// Call an anyhow-based function from rootcause code
fn legacy_function() -> anyhow::Result<String> {
anyhow::bail!("something went wrong");
}
fn new_function() -> Result<String, Report> {
// Convert seamlessly using .into_rootcause()
let value = legacy_function().into_rootcause()?;
Ok(value)
}The IntoRootcause trait is available for all supported external error
types, making it easy to integrate them with rootcause.
See the individual module documentation for detailed integration guides and migration strategies.
Modules§
- anyhow1
compat-anyhow1 - Bidirectional integration with the
anyhow1.x error handling library. - boxed_
error - Convert rootcause
Reports into boxed error trait objects. - error_
stack05 compat-error-stack05 - Bidirectional integration with the
error-stack0.5.x error handling library. - error_
stack06 compat-error-stack06 - Bidirectional integration with the
error-stack0.6.x error handling library. - eyre06
compat-eyre06 - Bidirectional integration with the
eyre0.6.x error handling library.
Structs§
- Report
AsError - A wrapper that adapts a rootcause
Reportto implementcore::error::Error.
Traits§
- Into
Rootcause - A trait for converting external error types into rootcause
Reports.