accumulate_context

Function accumulate_context 

Source
pub fn accumulate_context<E, I, C>(error: E, contexts: I) -> ComposableError<E>
where I: IntoIterator<Item = C>, C: IntoErrorContext,
Expand description

Wraps an error with multiple context entries at once.

Creates a ComposableError and attaches all provided contexts.

§Arguments

  • error - The core error to wrap
  • contexts - Iterator of contexts to attach

§Examples

use error_rail::{accumulate_context, ErrorContext};

let contexts = vec![ErrorContext::tag("auth"), ErrorContext::tag("api")];
let err = accumulate_context("unauthorized", contexts);
assert_eq!(err.context().len(), 2);