Expand description
Trait for converting types into structured error context.
This trait provides a unified interface for types that can be converted into
ErrorContext, enabling flexible context attachment in error handling pipelines.
§Implementations
The trait is implemented for common types:
String- Converts toErrorContext::Message&str- Converts toErrorContext::MessageErrorContext- Identity conversion (no-op)
§Examples
use error_rail::{traits::IntoErrorContext, ErrorContext};
let ctx1 = "simple message".into_error_context();
let ctx2 = String::from("owned message").into_error_context();
let ctx3 = ErrorContext::tag("network").into_error_context();
assert_eq!(ctx1.message(), "simple message");
assert_eq!(ctx2.message(), "owned message");
assert!(ctx3.message().contains("[network]"));Traits§
- Into
Error Context - Converts a type into an
ErrorContextfor error annotation.