with_context

Function with_context 

Source
pub fn with_context<E, C>(error: E, context: C) -> ComposableError<E>
Expand description

Wraps an error with a single context entry.

Creates a new ComposableError containing the given error and context.

§Arguments

  • error - The core error to wrap
  • context - Context information to attach

§Examples

use error_rail::{with_context, ErrorContext};

let err = with_context("io failed", ErrorContext::tag("disk"));
assert_eq!(err.context().len(), 1);