libimagentryedit: Rewrite error handling
This commit is contained in:
parent
ca0dd5906d
commit
4b4b0b0804
3 changed files with 8 additions and 8 deletions
|
@ -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())
|
||||
|
|
|
@ -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<Error>) -> Self::Target {
|
||||
fn into_error_with_cause(self, _: Box<Error>) -> Self::Target {
|
||||
EditError::from_kind(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
while_true,
|
||||
)]
|
||||
|
||||
#[macro_use] extern crate libimagerror;
|
||||
extern crate libimagerror;
|
||||
extern crate libimagstore;
|
||||
extern crate libimagrt;
|
||||
extern crate libimagutil;
|
||||
|
|
Loading…
Reference in a new issue