diff --git a/lib/domain/libimagnotes/src/error.rs b/lib/domain/libimagnotes/src/error.rs index b7a78805..b7b3ae9a 100644 --- a/lib/domain/libimagnotes/src/error.rs +++ b/lib/domain/libimagnotes/src/error.rs @@ -22,21 +22,15 @@ error_chain! { NoteError, NoteErrorKind, ResultExt, Result; } + links { + StoreError(::libimagstore::error::StoreError, ::libimagstore::error::StoreErrorKind); + } + foreign_links { TomlQueryError(::toml_query::error::Error); } errors { - StoreWriteError { - description("Error writing store") - display("Error writing store") - } - - StoreReadError { - description("Error reading store") - display("Error reading store") - } - HeaderTypeError { description("Header type error") display("Header type error") diff --git a/lib/domain/libimagnotes/src/note.rs b/lib/domain/libimagnotes/src/note.rs index 316257b9..001afeff 100644 --- a/lib/domain/libimagnotes/src/note.rs +++ b/lib/domain/libimagnotes/src/note.rs @@ -25,9 +25,8 @@ use toml_query::read::TomlValueReadTypeExt; use toml_query::set::TomlValueSetExt; use error::Result; -use error::NoteErrorKind as NEK; use error::NoteError as NE; -use error::ResultExt; +use error::NoteErrorKind as NEK; pub trait Note { fn set_name(&mut self, n: String) -> Result<()>; @@ -41,14 +40,13 @@ impl Note for Entry { fn set_name(&mut self, n: String) -> Result<()> { self.get_header_mut() .set("note.name", Value::String(n)) - .chain_err(|| NEK::StoreWriteError) + .map_err(NE::from) .map(|_| ()) } fn get_name(&self) -> Result { self.get_header() - .read_string("note.name") - .chain_err(|| NEK::StoreReadError)? + .read_string("note.name")? .ok_or(NE::from_kind(NEK::HeaderTypeError)) } diff --git a/lib/domain/libimagnotes/src/notestore.rs b/lib/domain/libimagnotes/src/notestore.rs index 756fdbf0..d75698bb 100644 --- a/lib/domain/libimagnotes/src/notestore.rs +++ b/lib/domain/libimagnotes/src/notestore.rs @@ -27,8 +27,7 @@ use toml_query::insert::TomlValueInsertExt; use module_path::ModuleEntryPath; use error::Result; -use error::NoteErrorKind as NEK; -use error::ResultExt; +use error::NoteError as NE; use iter::*; pub trait NoteStore<'a> { @@ -49,8 +48,7 @@ impl<'a> NoteStore<'a> for Store { let fle = { let mut lockentry = ModuleEntryPath::new(name.clone()) .into_storeid() - .and_then(|id| self.create(id)) - .chain_err(|| NEK::StoreWriteError)?; + .and_then(|id| self.create(id))?; { let entry = lockentry.deref_mut(); @@ -68,27 +66,27 @@ impl<'a> NoteStore<'a> for Store { ModuleEntryPath::new(name) .into_storeid() .and_then(|id| self.delete(id)) - .chain_err(|| NEK::StoreWriteError) + .map_err(NE::from) } fn retrieve_note(&'a self, name: String) -> Result> { ModuleEntryPath::new(name) .into_storeid() .and_then(|id| self.retrieve(id)) - .chain_err(|| NEK::StoreWriteError) + .map_err(NE::from) } fn get_note(&'a self, name: String) -> Result>> { ModuleEntryPath::new(name) .into_storeid() .and_then(|id| self.get(id)) - .chain_err(|| NEK::StoreWriteError) + .map_err(NE::from) } fn all_notes(&'a self) -> Result { self.retrieve_for_module("notes") .map(NoteIterator::new) - .chain_err(|| NEK::StoreReadError) + .map_err(NE::from) } }