Trait liquid_core::error::ResultLiquidExt

source ·
pub trait ResultLiquidExt<T>
where Self: Sized,
{ // Required methods fn trace<S>(self, trace: S) -> Result<T> where S: Into<KString>; fn trace_with<F>(self, trace: F) -> Result<T> where F: FnOnce() -> KString; fn context_key<S>(self, key: S) -> Key<T> where S: Into<KString>; fn context_key_with<F>(self, key: F) -> FnKey<T, F> where F: FnOnce() -> KString; }
Expand description

Add context to a crate::error::Error.

Required Methods§

source

fn trace<S>(self, trace: S) -> Result<T>
where S: Into<KString>,

Add a new stack frame to the crate::error::Error.

§Example
use liquid_core::error::Error;
use liquid_core::error::Result;
use liquid_core::error::ResultLiquidExt;

let error: Result<i32> = Err(Error::with_msg("Oops"));
let error = error.trace("Within forloop");
source

fn trace_with<F>(self, trace: F) -> Result<T>
where F: FnOnce() -> KString,

Add a new stack frame to the crate::error::Error.

§Example
use liquid_core::error::Error;
use liquid_core::error::Result;
use liquid_core::error::ResultLiquidExt;

let for_var = "foo";
let error: Result<i32> = Err(Error::with_msg("Oops"));
let error = error.trace_with(|| format!("Within forloop with {}", for_var).into());
source

fn context_key<S>(self, key: S) -> Key<T>
where S: Into<KString>,

Add state the current stack frame.

§Example
use liquid_core::error::Error;
use liquid_core::error::Result;
use liquid_core::error::ResultLiquidExt;

let for_var = "foo";
let error: Result<i32> = Err(Error::with_msg("Oops"));
let error = error
    .context_key("foo")
    .value("10");
let error = error
    .context_key("foo")
    .value_with(|| format!("{}", for_var).into());
source

fn context_key_with<F>(self, key: F) -> FnKey<T, F>
where F: FnOnce() -> KString,

Add state the current stack frame.

§Example
use liquid_core::error::Error;
use liquid_core::error::Result;
use liquid_core::error::ResultLiquidExt;

let for_var = "foo";
let error: Result<i32> = Err(Error::with_msg("Oops"));
let error = error
    .context_key_with(|| format!("{}", 10).into())
    .value("10");
let error = error
    .context_key_with(|| format!("{}", 10).into())
    .value_with(|| format!("{}", for_var).into());

Object Safety§

This trait is not object safe.

Implementors§