pub fn context_fn<E, C>(context: C) -> impl Fn(E) -> ComposableError<E>where
C: IntoErrorContext + Clone,Expand description
Creates a reusable closure that wraps errors with a fixed context.
Returns a function that can be used with map_err to attach the same
context to multiple error paths.
§Arguments
context- The context to attach (must beClone)
§Examples
use error_rail::{context_fn, ErrorContext};
let add_tag = context_fn(ErrorContext::tag("network"));
let err = add_tag("timeout");
assert_eq!(err.context().len(), 1);