imag-diary: Rewrite error handling

This commit is contained in:
Matthias Beyer 2017-09-03 20:45:23 +02:00
parent 54219cb6fa
commit 69b3fe52c6
3 changed files with 6 additions and 6 deletions

View file

@ -22,7 +22,7 @@ use std::process::exit;
use libimagdiary::diary::Diary;
use libimagdiary::diaryid::DiaryId;
use libimagdiary::error::DiaryErrorKind as DEK;
use libimagdiary::error::MapErrInto;
use libimagdiary::error::ResultExt;
use libimagentryedit::edit::Edit;
use libimagrt::runtime::Runtime;
use libimagerror::trace::trace_error;
@ -110,7 +110,7 @@ pub fn create(rt: &Runtime) {
Ok(())
} else {
debug!("Editing new diary entry");
entry.edit_content(rt).map_err_into(DEK::DiaryEditError)
entry.edit_content(rt).chain_err(|| DEK::DiaryEditError)
}
});

View file

@ -22,7 +22,7 @@ use chrono::naive::NaiveDateTime;
use libimagdiary::diary::Diary;
use libimagdiary::diaryid::DiaryId;
use libimagdiary::error::DiaryErrorKind as DEK;
use libimagdiary::error::MapErrInto;
use libimagdiary::error::ResultExt;
use libimagentryedit::edit::Edit;
use libimagrt::runtime::Runtime;
use libimagerror::trace::MapErrTrace;
@ -51,7 +51,7 @@ pub fn edit(rt: &Runtime) {
};
match to_edit {
Some(Ok(mut e)) => e.edit_content(rt).map_err_into(DEK::IOError),
Some(Ok(mut e)) => e.edit_content(rt).chain_err(|| DEK::IOError),
Some(Err(e)) => Err(e),
None => Err(DEK::EntryNotInDiary.into_error()),

View file

@ -19,7 +19,7 @@
use libimagdiary::diary::Diary;
use libimagdiary::error::DiaryErrorKind as DEK;
use libimagdiary::error::MapErrInto;
use libimagdiary::error::ResultExt;
use libimagentrylist::listers::core::CoreLister;
use libimagentrylist::lister::Lister;
use libimagrt::runtime::Runtime;
@ -59,7 +59,7 @@ pub fn list(rt: &Runtime) {
CoreLister::new(&entry_to_location_listing_string)
.list(es)
.map_err_into(DEK::IOError)
.chain_err(|| DEK::IOError)
})
.map_dbg_str("Ok")
.map_err_trace()