[][src]Trait liquid_error::ResultLiquidExt

pub trait ResultLiquidExt<T> where
    Self: Sized
{ #[must_use] fn trace<S>(self, trace: S) -> Result<T>
    where
        S: Into<Cow<'static, str>>
;
#[must_use] fn trace_with<F>(self, trace: F) -> Result<T>
    where
        F: FnOnce() -> Cow<'static, str>
;
#[must_use] fn context_key<S>(self, key: S) -> Key<T>
    where
        S: Into<Cow<'static, str>>
;
#[must_use] fn context_key_with<F>(self, key: F) -> FnKey<T, F>
    where
        F: FnOnce() -> Cow<'static, str>
; }

Add context to a liquid_error::Error.

Required methods

#[must_use] fn trace<S>(self, trace: S) -> Result<T> where
    S: Into<Cow<'static, str>>, 

Add a new stack frame to the liquid_error::Error.

Example

use liquid_error::Error;
use liquid_error::Result;
use liquid_error::ResultLiquidExt;

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

#[must_use] fn trace_with<F>(self, trace: F) -> Result<T> where
    F: FnOnce() -> Cow<'static, str>, 

Add a new stack frame to the liquid_error::Error.

Example

use liquid_error::Error;
use liquid_error::Result;
use liquid_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());

#[must_use] fn context_key<S>(self, key: S) -> Key<T> where
    S: Into<Cow<'static, str>>, 

Add state the current stack frame.

Example

use liquid_error::Error;
use liquid_error::Result;
use liquid_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());

#[must_use] fn context_key_with<F>(self, key: F) -> FnKey<T, F> where
    F: FnOnce() -> Cow<'static, str>, 

Add state the current stack frame.

Example

use liquid_error::Error;
use liquid_error::Result;
use liquid_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());
Loading content...

Implementors

impl<T> ResultLiquidExt<T> for Result<T>[src]

Loading content...