From 02b58a45c5bbf638187be8d62da7eeaf3f933c5e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 4 Sep 2016 17:54:04 +0200 Subject: [PATCH] Simplify error handling --- imag-diary/src/edit.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/imag-diary/src/edit.rs b/imag-diary/src/edit.rs index cc3362f3..bfcfa018 100644 --- a/imag-diary/src/edit.rs +++ b/imag-diary/src/edit.rs @@ -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(); }