imag-mail: Move from error-chain to failure

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2018-10-30 18:40:53 +01:00
parent fd2367b849
commit 5821a55c14
2 changed files with 8 additions and 3 deletions

View file

@ -23,6 +23,7 @@ maintenance = { status = "actively-developed" }
[dependencies] [dependencies]
log = "0.4.0" log = "0.4.0"
failure = "0.1"
libimagrt = { version = "0.9.0", path = "../../../lib/core/libimagrt" } libimagrt = { version = "0.9.0", path = "../../../lib/core/libimagrt" }
libimagerror = { version = "0.9.0", path = "../../../lib/core/libimagerror" } libimagerror = { version = "0.9.0", path = "../../../lib/core/libimagerror" }

View file

@ -34,6 +34,7 @@
extern crate clap; extern crate clap;
#[macro_use] extern crate log; #[macro_use] extern crate log;
extern crate failure;
#[macro_use] extern crate libimagrt; #[macro_use] extern crate libimagrt;
extern crate libimagmail; extern crate libimagmail;
@ -42,6 +43,9 @@ extern crate libimagutil;
use std::io::Write; use std::io::Write;
use failure::Error;
use failure::err_msg;
use libimagerror::trace::{MapErrTrace, trace_error}; use libimagerror::trace::{MapErrTrace, trace_error};
use libimagerror::iter::TraceIterator; use libimagerror::iter::TraceIterator;
use libimagerror::exit::ExitUnwrap; use libimagerror::exit::ExitUnwrap;
@ -91,8 +95,7 @@ fn import_mail(rt: &Runtime) {
} }
fn list(rt: &Runtime) { fn list(rt: &Runtime) {
use libimagmail::error::MailErrorKind as MEK; use failure::ResultExt;
use libimagmail::error::ResultExt;
// TODO: Implement lister type in libimagmail for this // TODO: Implement lister type in libimagmail for this
fn list_mail(rt: &Runtime, m: Mail) { fn list_mail(rt: &Runtime, m: Mail) {
@ -149,7 +152,8 @@ fn list(rt: &Runtime) {
.filter_map(|id| { .filter_map(|id| {
rt.store() rt.store()
.get(id) .get(id)
.chain_err(|| MEK::RefHandlingError) .context(err_msg("Ref handling error"))
.map_err(Error::from)
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
.map(|fle| Mail::from_fle(fle).map_err_trace().ok()) .map(|fle| Mail::from_fle(fle).map_err_trace().ok())
}) })