imag-mail: Rewrite error handling

This commit is contained in:
Matthias Beyer 2017-09-03 20:46:32 +02:00
parent 69b3fe52c6
commit 2b845c773b

View file

@ -68,14 +68,14 @@ fn import_mail(rt: &Runtime) {
fn list(rt: &Runtime) { fn list(rt: &Runtime) {
use libimagmail::error::MailErrorKind as MEK; use libimagmail::error::MailErrorKind as MEK;
use libimagmail::error::MapErrInto; use libimagmail::error::ResultExt;
let store = rt.store(); let store = rt.store();
let iter = match store.retrieve_for_module("ref") { let iter = match store.retrieve_for_module("ref") {
Ok(iter) => iter.filter_map(|id| { Ok(iter) => iter.filter_map(|id| {
Ref::get(store, id) Ref::get(store, id)
.map_err_into(MEK::RefHandlingError) .chain_err(|| MEK::RefHandlingError)
.and_then(|rf| Mail::from_ref(rf)) .and_then(|rf| Mail::from_ref(rf))
.map_err_trace() .map_err_trace()
.ok() .ok()