group

Macro group 

Source
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 message
  • tag("label") - Categorical tags (can be repeated)
  • location(file, line) - Source file and line number
  • metadata("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")
    ));