summaryrefslogtreecommitdiffstats
path: root/lib/entry/libimagentrylist/src/listers/path.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-09-03 15:10:11 +0200
committerMatthias Beyer <mail@beyermatthias.de>2017-09-03 21:33:54 +0200
commit9aa5d7439d864aeeb9667f08f3d83eb60605cffa (patch)
tree7eb5346e9e13579a418a770a1cd6e4b1bf6f3ff8 /lib/entry/libimagentrylist/src/listers/path.rs
parent4b4b0b0804cabdd81d0a8341aa520bc4d5e2fa0f (diff)
libimagentrylist: Rewrite error handling
Diffstat (limited to 'lib/entry/libimagentrylist/src/listers/path.rs')
-rw-r--r--lib/entry/libimagentrylist/src/listers/path.rs19
1 files changed, 4 insertions, 15 deletions
diff --git a/lib/entry/libimagentrylist/src/listers/path.rs b/lib/entry/libimagentrylist/src/listers/path.rs
index 15a2df5b..55a9afb0 100644
--- a/lib/entry/libimagentrylist/src/listers/path.rs
+++ b/lib/entry/libimagentrylist/src/listers/path.rs
@@ -22,7 +22,7 @@ use std::io::Write;
use lister::Lister;
use result::Result;
-use error::MapErrInto;
+use error::ResultExt;
use libimagstore::store::FileLockEntry;
use libimagutil::iter::FoldResult;
@@ -44,30 +44,19 @@ impl PathLister {
impl Lister for PathLister {
fn list<'a, I: Iterator<Item = FileLockEntry<'a>>>(&self, entries: I) -> Result<()> {
- use error::ListError as LE;
use error::ListErrorKind as LEK;
entries.fold_result(|entry| {
Ok(entry.get_location().clone())
- .and_then(|pb| pb.into_pathbuf().map_err_into(LEK::FormatError))
+ .and_then(|pb| pb.into_pathbuf().chain_err(|| LEK::FormatError))
.and_then(|pb| {
if self.absolute {
- pb.canonicalize().map_err(|e| LE::new(LEK::FormatError, Some(Box::new(e))))
+ pb.canonicalize().chain_err(|| LEK::FormatError)
} else {
Ok(pb.into())
}
})
- .and_then(|pb| {
- write!(stdout(), "{:?}\n", pb)
- .map_err(|e| LE::new(LEK::FormatError, Some(Box::new(e))))
- })
- .map_err(|e| {
- if e.err_type() == LEK::FormatError {
- e
- } else {
- LE::new(LEK::FormatError, Some(Box::new(e)))
- }
- })
+ .and_then(|pb| write!(stdout(), "{:?}\n", pb).chain_err(|| LEK::FormatError))
})
}