macro_rules! group {
() => { ... };
(
$($field:ident($($arg:tt)*)),* $(,)?
) => { ... };
}Expand description
Creates a grouped error context that combines multiple context types.
This macro creates a lazily-evaluated grouped context that combines message, tags, location, and metadata into a single cohesive unit. All formatting is deferred until the error actually occurs, avoiding unnecessary allocations on the success path.
§Arguments
The macro accepts function-call style arguments:
message("format string", args...)- Optional formatted messagetag("label")- Categorical tags (can be repeated)location(file, line)- Source file and line numbermetadata("key", "value")- Key-value pairs (can be repeated)
§Examples
use error_rail::{group, ComposableError};
let attempts = 3;
let err = ComposableError::<&str>::new("auth failed")
.with_context(group!(
message("user_id: {}", attempts),
tag("auth"),
location(file!(), line!()),
metadata("retry_count", "3"),
metadata("timeout", "30s")
));