[][src]Trait avocado::error::ResultExt

pub trait ResultExt<T>: Sized {
    fn chain<M: ErrMsg>(self, message: M) -> Result<T>;
}

A trait for conveniently propagating errors up the call stack.

Required methods

fn chain<M: ErrMsg>(self, message: M) -> Result<T>

If this Result is an Err, then prepend the specified error to the front of the linked list of causes.

let ok: Result<_> = Ok("success!");
let ok_chained = ok.chain("dummy error message")?;
assert_eq!(ok_chained, "success!");

let err: Result<i32> = Err(Error::new(
    ErrorKind::MongoDbError, "chained cause"
));
let err_chained = err.chain("top-level message").unwrap_err();
assert_eq!(err_chained.description(), "top-level message");
assert_eq!(err_chained.kind(), ErrorKind::MongoDbError);
Loading content...

Implementations on Foreign Types

impl<T, E> ResultExt<T> for Result<T, E> where
    E: ErrorExt + 'static, 
[src]

Loading content...

Implementors

Loading content...