Simplify error handling

This commit is contained in:
Matthias Beyer 2016-09-04 17:54:04 +02:00
parent 4ddb558837
commit 02b58a45c5

View file

@ -3,11 +3,12 @@ use chrono::naive::datetime::NaiveDateTime;
use libimagdiary::diary::Diary;
use libimagdiary::diaryid::DiaryId;
use libimagdiary::error::DiaryError as DE;
use libimagdiary::error::DiaryErrorKind as DEK;
use libimagdiary::error::MapErrInto;
use libimagentryedit::edit::Edit;
use libimagrt::runtime::Runtime;
use libimagerror::trace::trace_error;
use libimagerror::into::IntoError;
use libimagtimeui::datetime::DateTime;
use libimagtimeui::parse::Parse;
@ -36,10 +37,10 @@ pub fn edit(rt: &Runtime) {
};
match to_edit {
Some(Ok(mut e)) => e.edit_content(rt).map_err(|e| DE::new(DEK::IOError, Some(Box::new(e)))),
Some(Ok(mut e)) => e.edit_content(rt).map_err_into(DEK::IOError),
Some(Err(e)) => Err(e),
None => Err(DE::new(DEK::EntryNotInDiary, None)),
None => Err(DEK::EntryNotInDiary.into_error()),
}
.map_err(|e| trace_error(&e)).ok();
}