imag-diary: Use Err/Ok Result map utils to refactor code
This commit is contained in:
parent
473e6d5b6a
commit
a39f07f9a5
2 changed files with 10 additions and 10 deletions
|
@ -6,7 +6,7 @@ use libimagdiary::error::DiaryErrorKind as DEK;
|
||||||
use libimagdiary::error::MapErrInto;
|
use libimagdiary::error::MapErrInto;
|
||||||
use libimagentryedit::edit::Edit;
|
use libimagentryedit::edit::Edit;
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
use libimagerror::trace::trace_error;
|
use libimagerror::trace::MapErrTrace;
|
||||||
use libimagerror::into::IntoError;
|
use libimagerror::into::IntoError;
|
||||||
use libimagtimeui::datetime::DateTime;
|
use libimagtimeui::datetime::DateTime;
|
||||||
use libimagtimeui::parse::Parse;
|
use libimagtimeui::parse::Parse;
|
||||||
|
@ -37,7 +37,7 @@ pub fn edit(rt: &Runtime) {
|
||||||
Some(Err(e)) => Err(e),
|
Some(Err(e)) => Err(e),
|
||||||
None => Err(DEK::EntryNotInDiary.into_error()),
|
None => Err(DEK::EntryNotInDiary.into_error()),
|
||||||
}
|
}
|
||||||
.map_err(|e| trace_error(&e)).ok();
|
.map_err_trace().ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,9 @@ use libimagentrylist::listers::core::CoreLister;
|
||||||
use libimagentrylist::lister::Lister;
|
use libimagentrylist::lister::Lister;
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
use libimagstore::store::Entry;
|
use libimagstore::store::Entry;
|
||||||
use libimagerror::trace::trace_error;
|
|
||||||
use libimagutil::warn_exit::warn_exit;
|
use libimagutil::warn_exit::warn_exit;
|
||||||
|
use libimagerror::trace::MapErrTrace;
|
||||||
|
use libimagutil::debug_result::*;
|
||||||
|
|
||||||
use util::get_diary_name;
|
use util::get_diary_name;
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ pub fn list(rt: &Runtime) {
|
||||||
e.get_location().clone()
|
e.get_location().clone()
|
||||||
.without_base()
|
.without_base()
|
||||||
.to_str()
|
.to_str()
|
||||||
.map_err(|e| trace_error(&e))
|
.map_err_trace()
|
||||||
.unwrap_or(String::from("<<Path Parsing Error>>"))
|
.unwrap_or(String::from("<<Path Parsing Error>>"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,17 +29,16 @@ pub fn list(rt: &Runtime) {
|
||||||
.and_then(|es| {
|
.and_then(|es| {
|
||||||
debug!("Iterator for listing: {:?}", es);
|
debug!("Iterator for listing: {:?}", es);
|
||||||
|
|
||||||
let es = es.filter_map(|a| {
|
let es = es
|
||||||
debug!("Filtering: {:?}", a);
|
.filter_map(|a| a.map_dbg(|e| format!("Filtering: {:?}", e)).ok())
|
||||||
a.ok()
|
.map(|e| e.into());
|
||||||
}).map(|e| e.into());
|
|
||||||
|
|
||||||
CoreLister::new(&entry_to_location_listing_string)
|
CoreLister::new(&entry_to_location_listing_string)
|
||||||
.list(es) // TODO: Do not ignore non-ok()s
|
.list(es) // TODO: Do not ignore non-ok()s
|
||||||
.map_err_into(DEK::IOError)
|
.map_err_into(DEK::IOError)
|
||||||
})
|
})
|
||||||
.map(|_| debug!("Ok"))
|
.map_dbg_str("Ok")
|
||||||
.map_err(|e| trace_error(&e))
|
.map_err_trace()
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue