with_context_result

Function with_context_result 

Source
pub fn with_context_result<T, E, C>(
    result: Result<T, E>,
    context: C,
) -> BoxedComposableResult<T, E>
Expand description

Transforms a Result by adding context to any error.

On Err, wraps the error in a boxed ComposableError with the provided context. On Ok, returns the success value unchanged.

§Arguments

  • result - The result to transform
  • context - Context to attach on error

§Examples

use error_rail::{with_context_result, ErrorContext};

let result: Result<i32, &str> = Err("failed");
let enriched = with_context_result(result, ErrorContext::tag("auth"));
assert!(enriched.is_err());