From be094dcfae21fb20c6e6a5015503f64e38647709 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 4 Dec 2015 14:04:20 +0100 Subject: [PATCH] StorageBackend::iter_files() return Result<> with StorageBackendError on error --- src/storage/backend.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/storage/backend.rs b/src/storage/backend.rs index b349c166..2f39c5ae 100644 --- a/src/storage/backend.rs +++ b/src/storage/backend.rs @@ -92,14 +92,22 @@ impl StorageBackend { } pub fn iter_files<'a, HP>(&self, m: &'a Module, p: &Parser) - -> Option>> + -> Result>, StorageBackendError> where HP: FileHeaderParser { - self.iter_ids(m).and_then(|ids| { - Some(ids.filter_map(|id| self.get_file_by_id(m, &id, p)) - .collect::>() - .into_iter()) - }) + self.iter_ids(m) + .and_then(|ids| { + Ok(ids.filter_map(|id| self.get_file_by_id(m, &id, p)) + .collect::>() + .into_iter()) + }) + .map_err(|e| { + let serr = StorageBackendError::build( + "iter_files()", + "Cannot iter on files", + None); + serr + }) } /*