[][src]Trait liquid_error::ResultLiquidExt

pub trait ResultLiquidExt<T> where
    Self: Sized
{ 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
;
#[must_use] fn context_key<S>(self, key: S) -> Key<T>
    where
        S: Into<KString>
;
#[must_use] fn context_key_with<F>(self, key: F) -> FnKey<T, F>
    where
        F: FnOnce() -> KString
; }

Add context to a liquid_error::Error.

Required methods

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

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");

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

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<KString>, 

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() -> KString

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...