libimagentryview: Rewrite error handling
This commit is contained in:
parent
0ede39a991
commit
5b781702cc
3 changed files with 8 additions and 9 deletions
|
@ -23,8 +23,8 @@ use libimagentryedit::edit::edit_in_tmpfile;
|
||||||
|
|
||||||
use viewer::Viewer;
|
use viewer::Viewer;
|
||||||
use result::Result;
|
use result::Result;
|
||||||
|
use error::ResultExt;
|
||||||
use error::ViewErrorKind as VEK;
|
use error::ViewErrorKind as VEK;
|
||||||
use error::ViewError as VE;
|
|
||||||
|
|
||||||
pub struct EditorView<'a>(&'a Runtime<'a>);
|
pub struct EditorView<'a>(&'a Runtime<'a>);
|
||||||
|
|
||||||
|
@ -37,8 +37,7 @@ impl<'a> EditorView<'a> {
|
||||||
impl<'a> Viewer for EditorView<'a> {
|
impl<'a> Viewer for EditorView<'a> {
|
||||||
fn view_entry(&self, e: &Entry) -> Result<()> {
|
fn view_entry(&self, e: &Entry) -> Result<()> {
|
||||||
let mut entry = e.to_str().clone().to_string();
|
let mut entry = e.to_str().clone().to_string();
|
||||||
edit_in_tmpfile(self.0, &mut entry)
|
edit_in_tmpfile(self.0, &mut entry).chain_err(|| VEK::ViewError)
|
||||||
.map_err(|e| VE::new(VEK::ViewError, Some(Box::new(e))))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
//
|
//
|
||||||
|
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
|
use libimagerror::into::IntoError;
|
||||||
|
|
||||||
error_chain! {
|
error_chain! {
|
||||||
types {
|
types {
|
||||||
ViewError, ViewErrorKind, ResultExt, Result;
|
ViewError, ViewErrorKind, ResultExt, Result;
|
||||||
|
@ -51,10 +55,6 @@ error_chain! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use self::error::ViewError;
|
|
||||||
pub use self::error::ViewErrorKind;
|
|
||||||
pub use self::error::MapErrInto;
|
|
||||||
|
|
||||||
impl IntoError for ViewErrorKind {
|
impl IntoError for ViewErrorKind {
|
||||||
type Target = ViewError;
|
type Target = ViewError;
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ impl IntoError for ViewErrorKind {
|
||||||
ViewError::from_kind(self)
|
ViewError::from_kind(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn into_error_with_cause(self, cause: Box<Error>) -> Self::Target {
|
fn into_error_with_cause(self, _: Box<Error>) -> Self::Target {
|
||||||
ViewError::from_kind(self)
|
ViewError::from_kind(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ extern crate toml;
|
||||||
|
|
||||||
extern crate libimagstore;
|
extern crate libimagstore;
|
||||||
extern crate libimagrt;
|
extern crate libimagrt;
|
||||||
#[macro_use] extern crate libimagerror;
|
extern crate libimagerror;
|
||||||
extern crate libimagentryedit;
|
extern crate libimagentryedit;
|
||||||
|
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
|
Loading…
Reference in a new issue