[−][src]Trait failure_ext::FutureExt
Extension methods for trait Future
.
Required methods
fn context<D>(
self,
context: D
) -> Box<dyn Future<Item = F::Item, Error = Error>> where
D: Display + Send + Sync + 'static,
self,
context: D
) -> Box<dyn Future<Item = F::Item, Error = Error>> where
D: Display + Send + Sync + 'static,
Wraps the error type in a context type.
Examples
fn get_future() -> impl Future<Item = (), Error = failure::Error> { futures::future::err(err_msg("abcd")) } let x = get_future() .context(format!("An error occured")) .wait() .unwrap_err(); let x = format!("{}", x); assert_eq!(x, "An error occured");