diff --git a/lib/domain/libimaghabit/src/habit.rs b/lib/domain/libimaghabit/src/habit.rs index 36c9dcc0..cd53c290 100644 --- a/lib/domain/libimaghabit/src/habit.rs +++ b/lib/domain/libimaghabit/src/habit.rs @@ -131,7 +131,8 @@ impl HabitTemplate for Entry { let iter = self .get_internal_links()? .map(|link| link.get_store_id().clone()) - .filter(IsHabitCheck::is_habit_instance); + .filter(IsHabitCheck::is_habit_instance) + .map(Ok); let sidi = StoreIdIterator::new(Box::new(iter)); Ok(HabitInstanceStoreIdIterator::new(sidi)) diff --git a/lib/domain/libimaghabit/src/iter.rs b/lib/domain/libimaghabit/src/iter.rs index fa64f1ae..6a1af765 100644 --- a/lib/domain/libimaghabit/src/iter.rs +++ b/lib/domain/libimaghabit/src/iter.rs @@ -22,16 +22,21 @@ use libimagstore::storeid::StoreIdIteratorWithStore; use libimagstore::storeid::StoreId; use util::IsHabitCheck; +use error::Result; +use error::HabitError as HE; pub struct HabitTemplateStoreIdIterator(StoreIdIterator); impl Iterator for HabitTemplateStoreIdIterator { - type Item = StoreId; + type Item = Result; fn next(&mut self) -> Option { while let Some(n) = self.0.next() { - if n.is_habit_template() { - return Some(n) + match n { + Ok(n) => if n.is_habit_template() { + return Some(Ok(n)) + }, + Err(e) => return Some(Err(e).map_err(HE::from)), } } None @@ -59,12 +64,15 @@ impl HabitInstanceStoreIdIterator { } impl Iterator for HabitInstanceStoreIdIterator { - type Item = StoreId; + type Item = Result; fn next(&mut self) -> Option { while let Some(n) = self.0.next() { - if n.is_habit_instance() { - return Some(n) + match n { + Ok(n) => if n.is_habit_instance() { + return Some(Ok(n)); + }, + Err(e) => return Some(Err(e).map_err(HE::from)), } } None