diff --git a/lib/domain/libimagnotes/src/iter.rs b/lib/domain/libimagnotes/src/iter.rs index 74908c8f..3dc2047e 100644 --- a/lib/domain/libimagnotes/src/iter.rs +++ b/lib/domain/libimagnotes/src/iter.rs @@ -23,6 +23,7 @@ use libimagstore::storeid::StoreIdIterator; use crate::notestoreid::*; use failure::Fallible as Result; use failure::Error; +use failure::ResultExt; #[derive(Debug)] pub struct NoteIterator(StoreIdIterator); @@ -40,11 +41,11 @@ impl Iterator for NoteIterator { fn next(&mut self) -> Option { while let Some(n) = self.0.next() { - match n { + match n.context("Error while iterating").map_err(Error::from) { Ok(n) => if n.is_note_id() { return Some(Ok(n)); }, - Err(e) => return Some(Err(e).map_err(Error::from)), + Err(e) => return Some(Err(e)), } } diff --git a/lib/domain/libimagnotes/src/note.rs b/lib/domain/libimagnotes/src/note.rs index 2a55ce2b..15a0142f 100644 --- a/lib/domain/libimagnotes/src/note.rs +++ b/lib/domain/libimagnotes/src/note.rs @@ -27,6 +27,7 @@ use toml_query::set::TomlValueSetExt; use failure::Fallible as Result; use failure::Error; +use failure::ResultExt; pub trait Note { fn set_name(&mut self, n: String) -> Result<()>; @@ -40,6 +41,7 @@ impl Note for Entry { fn set_name(&mut self, n: String) -> Result<()> { self.get_header_mut() .set("note.name", Value::String(n)) + .context(format_err!("Cannot set 'note.name' in header of {}", self.get_location())) .map_err(Error::from) .map(|_| ()) }