From 69b3fe52c624613bdc87703341ef516078977982 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 3 Sep 2017 20:45:23 +0200 Subject: [PATCH] imag-diary: Rewrite error handling --- bin/domain/imag-diary/src/create.rs | 4 ++-- bin/domain/imag-diary/src/edit.rs | 4 ++-- bin/domain/imag-diary/src/list.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/domain/imag-diary/src/create.rs b/bin/domain/imag-diary/src/create.rs index 78f679a7..e49cae25 100644 --- a/bin/domain/imag-diary/src/create.rs +++ b/bin/domain/imag-diary/src/create.rs @@ -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) } }); diff --git a/bin/domain/imag-diary/src/edit.rs b/bin/domain/imag-diary/src/edit.rs index 1cd5f9e5..a5f5e616 100644 --- a/bin/domain/imag-diary/src/edit.rs +++ b/bin/domain/imag-diary/src/edit.rs @@ -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()), diff --git a/bin/domain/imag-diary/src/list.rs b/bin/domain/imag-diary/src/list.rs index 4ed3123c..f915712f 100644 --- a/bin/domain/imag-diary/src/list.rs +++ b/bin/domain/imag-diary/src/list.rs @@ -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()