diff --git a/lib/entry/libimagentryannotation/src/annotateable.rs b/lib/entry/libimagentryannotation/src/annotateable.rs index 4906b174..d38b9c66 100644 --- a/lib/entry/libimagentryannotation/src/annotateable.rs +++ b/lib/entry/libimagentryannotation/src/annotateable.rs @@ -92,7 +92,7 @@ impl Annotateable for Entry { fn annotations<'a>(&self, store: &'a Store) -> Result> { self.get_internal_links() .map_err(From::from) - .map(|iter| StoreIdIterator::new(Box::new(iter.map(|e| e.get_store_id().clone())))) + .map(|iter| StoreIdIterator::new(Box::new(iter.map(|e| e.get_store_id().clone()).map(Ok)))) .map(|i| AnnotationIter::new(i, store)) } diff --git a/lib/entry/libimagentryannotation/src/iter.rs b/lib/entry/libimagentryannotation/src/iter.rs index 996c6ffd..9485ba07 100644 --- a/lib/entry/libimagentryannotation/src/iter.rs +++ b/lib/entry/libimagentryannotation/src/iter.rs @@ -24,6 +24,7 @@ use libimagstore::store::FileLockEntry; use libimagstore::storeid::StoreIdIterator; use error::Result; +use error::AnnotationError as AE; use error::AnnotationErrorKind as AEK; use error::ResultExt; @@ -43,18 +44,21 @@ impl<'a> Iterator for AnnotationIter<'a> { fn next(&mut self) -> Option { loop { - match self.0.next().map(|id| self.1.get(id)) { - Some(Ok(Some(entry))) => { - match entry.get_header().read_bool("annotation.is_annotation").chain_err(|| AEK::HeaderReadError) { - Ok(None) => continue, // not an annotation - Ok(Some(false)) => continue, - Ok(Some(true)) => return Some(Ok(entry)), - Err(e) => return Some(Err(e)), - } - }, - Some(Ok(None)) => continue, - Some(Err(e)) => return Some(Err(e).chain_err(|| AEK::StoreReadError)), - None => return None, // iterator consumed + match self.0.next() { + None => return None, // iterator consumed + Some(Err(e)) => return Some(Err(e).map_err(AE::from)), + Some(Ok(id)) => match self.1.get(id) { + Err(e) => return Some(Err(e).chain_err(|| AEK::StoreReadError)), + Ok(Some(entry)) => { + match entry.get_header().read_bool("annotation.is_annotation").chain_err(|| AEK::HeaderReadError) { + Ok(None) => continue, // not an annotation + Ok(Some(false)) => continue, + Ok(Some(true)) => return Some(Ok(entry)), + Err(e) => return Some(Err(e)), + } + }, + Ok(None) => continue, + } } } }