From 5821a55c144421f3086229cd8424c21172c22014 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 30 Oct 2018 18:40:53 +0100 Subject: [PATCH] imag-mail: Move from error-chain to failure Signed-off-by: Matthias Beyer --- bin/domain/imag-mail/Cargo.toml | 1 + bin/domain/imag-mail/src/main.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/domain/imag-mail/Cargo.toml b/bin/domain/imag-mail/Cargo.toml index 08ecff00..5dc1b710 100644 --- a/bin/domain/imag-mail/Cargo.toml +++ b/bin/domain/imag-mail/Cargo.toml @@ -23,6 +23,7 @@ maintenance = { status = "actively-developed" } [dependencies] log = "0.4.0" +failure = "0.1" libimagrt = { version = "0.9.0", path = "../../../lib/core/libimagrt" } libimagerror = { version = "0.9.0", path = "../../../lib/core/libimagerror" } diff --git a/bin/domain/imag-mail/src/main.rs b/bin/domain/imag-mail/src/main.rs index f36e01c4..c7975480 100644 --- a/bin/domain/imag-mail/src/main.rs +++ b/bin/domain/imag-mail/src/main.rs @@ -34,6 +34,7 @@ extern crate clap; #[macro_use] extern crate log; +extern crate failure; #[macro_use] extern crate libimagrt; extern crate libimagmail; @@ -42,6 +43,9 @@ extern crate libimagutil; use std::io::Write; +use failure::Error; +use failure::err_msg; + use libimagerror::trace::{MapErrTrace, trace_error}; use libimagerror::iter::TraceIterator; use libimagerror::exit::ExitUnwrap; @@ -91,8 +95,7 @@ fn import_mail(rt: &Runtime) { } fn list(rt: &Runtime) { - use libimagmail::error::MailErrorKind as MEK; - use libimagmail::error::ResultExt; + use failure::ResultExt; // TODO: Implement lister type in libimagmail for this fn list_mail(rt: &Runtime, m: Mail) { @@ -149,7 +152,8 @@ fn list(rt: &Runtime) { .filter_map(|id| { rt.store() .get(id) - .chain_err(|| MEK::RefHandlingError) + .context(err_msg("Ref handling error")) + .map_err(Error::from) .map_err_trace_exit_unwrap(1) .map(|fle| Mail::from_fle(fle).map_err_trace().ok()) })