diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-08-03 11:10:56 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-08-03 11:27:25 +0200 |
commit | f46e8ac5977a546425d8ba565de68adb3207a284 (patch) | |
tree | eda1cfcd16e8fc3f6914e6fda1bc336f6d935438 /libimagentrylink | |
parent | ca08f6d2739f4fe56760fe1b9b6ce59c0537c80c (diff) |
Replace unwrap with try!()
Diffstat (limited to 'libimagentrylink')
-rw-r--r-- | libimagentrylink/src/external.rs | 14 | ||||
-rw-r--r-- | libimagentrylink/src/internal.rs | 1 |
2 files changed, 9 insertions, 6 deletions
diff --git a/libimagentrylink/src/external.rs b/libimagentrylink/src/external.rs index e1bc2535..a92b8af1 100644 --- a/libimagentrylink/src/external.rs +++ b/libimagentrylink/src/external.rs @@ -19,9 +19,11 @@ use libimagstore::store::FileLockEntry; use libimagstore::store::Store; use libimagstore::storeid::StoreId; use libimagstore::storeid::IntoStoreId; +use libimagutil::debug_result::*; use error::LinkError as LE; use error::LinkErrorKind as LEK; +use error::MapErrInto; use result::Result; use internal::InternalLinker; use module_path::ModuleEntryPath; @@ -150,12 +152,12 @@ impl ExternalLinker for Entry { // retrieve the file from the store, which implicitely creates the entry if it does not // exist - let file = store.retrieve(file_id.clone()); - if file.is_err() { - debug!("Failed to create or retrieve an file for this link '{:?}'", link); - return Err(LE::new(LEK::StoreWriteError, Some(Box::new(file.unwrap_err())))); - } - let mut file = file.unwrap(); + let mut file = try!(store + .retrieve(file_id.clone()) + .map_err_into(LEK::StoreWriteError) + .map_dbg_err(|_| { + format!("Failed to create or retrieve an file for this link '{:?}'", link) + })); debug!("Generating header content!"); { diff --git a/libimagentrylink/src/internal.rs b/libimagentrylink/src/internal.rs index 02be0e7e..d93b14c2 100644 --- a/libimagentrylink/src/internal.rs +++ b/libimagentrylink/src/internal.rs @@ -7,6 +7,7 @@ use libimagstore::store::Result as StoreResult; use libimagerror::into::IntoError; use error::LinkErrorKind as LEK; +use error::MapErrInto; use result::Result; use toml::Value; |