summaryrefslogtreecommitdiffstats
path: root/libimagstore
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-05-26 22:16:29 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-05-26 22:16:29 +0200
commitfdb5d1bb24377884fc8827d5895d1a0149017c3a (patch)
tree77d0084cb14bdc1ac867fc680cb261bfc3d55f2a /libimagstore
parent2e80c29f47658a95023805a9a149058570bea16a (diff)
Replace old error construction code with new libimagerror functionality
Diffstat (limited to 'libimagstore')
-rw-r--r--libimagstore/src/lazyfile.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/libimagstore/src/lazyfile.rs b/libimagstore/src/lazyfile.rs
index ec3e8f45..5079b686 100644
--- a/libimagstore/src/lazyfile.rs
+++ b/libimagstore/src/lazyfile.rs
@@ -1,3 +1,4 @@
+use libimagerror::into::IntoError;
use error::{StoreError, StoreErrorKind};
use std::io::{Seek, SeekFrom};
@@ -39,14 +40,15 @@ impl LazyFile {
// We seek to the beginning of the file since we expect each
// access to the file to be in a different context
f.seek(SeekFrom::Start(0))
- .map_err(|e| StoreError::new(StoreErrorKind::FileNotCreated, Some(Box::new(e))))
+ .map_err(Box::new)
+ .map_err(|e| StoreErrorKind::FileNotCreated.into_error_with_cause(e))
.map(|_| f)
},
LazyFile::Absent(ref p) => {
- try!(open_file(p).map_err(|e| {
- StoreError::new(StoreErrorKind::FileNotFound,
- Some(Box::new(e)))
- }))
+ try!(open_file(p)
+ .map_err(Box::new)
+ .map_err(|e| StoreErrorKind::FileNotFound.into_error_with_cause(e))
+ )
}
};
*self = LazyFile::File(file);
@@ -64,10 +66,10 @@ impl LazyFile {
let file = match *self {
LazyFile::File(ref mut f) => return Ok(f),
LazyFile::Absent(ref p) => {
- try!(create_file(p).map_err(|e| {
- StoreError::new(StoreErrorKind::FileNotFound,
- Some(Box::new(e)))
- }))
+ try!(create_file(p)
+ .map_err(Box::new)
+ .map_err(|e| StoreErrorKind::FileNotFound.into_error_with_cause(e))
+ )
}
};
*self = LazyFile::File(file);