From 4b4b0b0804cabdd81d0a8341aa520bc4d5e2fa0f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 3 Sep 2017 15:03:52 +0200 Subject: [PATCH] libimagentryedit: Rewrite error handling --- lib/entry/libimagentryedit/src/edit.rs | 4 ++-- lib/entry/libimagentryedit/src/error.rs | 10 +++++----- lib/entry/libimagentryedit/src/lib.rs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/entry/libimagentryedit/src/edit.rs b/lib/entry/libimagentryedit/src/edit.rs index cbd17733..0e5900a2 100644 --- a/lib/entry/libimagentryedit/src/edit.rs +++ b/lib/entry/libimagentryedit/src/edit.rs @@ -23,7 +23,7 @@ use libimagstore::store::Entry; use result::Result; use error::EditErrorKind; -use error::MapErrInto; +use error::ResultExt; pub trait Edit { fn edit_content(&mut self, rt: &Runtime) -> Result<()>; @@ -53,7 +53,7 @@ pub fn edit_in_tmpfile(rt: &Runtime, s: &mut String) -> Result<()> { .ok_or(EditErrorKind::NoEditor.into_error()) .and_then(|editor| { edit_in_tmpfile_with_command(editor, s) - .map_err_into(EditErrorKind::IOError) + .chain_err(|| EditErrorKind::IOError) .and_then(|worked| { if !worked { Err(EditErrorKind::ProcessExitFailure.into()) diff --git a/lib/entry/libimagentryedit/src/error.rs b/lib/entry/libimagentryedit/src/error.rs index a37c7e80..2bc81b19 100644 --- a/lib/entry/libimagentryedit/src/error.rs +++ b/lib/entry/libimagentryedit/src/error.rs @@ -17,6 +17,10 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // +use std::error::Error; + +use libimagerror::into::IntoError; + error_chain! { types { EditError, EditErrorKind, ResultExt, Result; @@ -46,10 +50,6 @@ error_chain! { } } -pub use self::error::EditError; -pub use self::error::EditErrorKind; -pub use self::error::MapErrInto; - impl IntoError for EditErrorKind { type Target = EditError; @@ -57,7 +57,7 @@ impl IntoError for EditErrorKind { EditError::from_kind(self) } - fn into_error_with_cause(self, cause: Box) -> Self::Target { + fn into_error_with_cause(self, _: Box) -> Self::Target { EditError::from_kind(self) } } diff --git a/lib/entry/libimagentryedit/src/lib.rs b/lib/entry/libimagentryedit/src/lib.rs index ca054538..6776476f 100644 --- a/lib/entry/libimagentryedit/src/lib.rs +++ b/lib/entry/libimagentryedit/src/lib.rs @@ -35,7 +35,7 @@ while_true, )] -#[macro_use] extern crate libimagerror; +extern crate libimagerror; extern crate libimagstore; extern crate libimagrt; extern crate libimagutil;