Replace unwrap with try!()

This commit is contained in:
Matthias Beyer 2016-08-03 11:10:56 +02:00
parent ca08f6d273
commit f46e8ac597
2 changed files with 9 additions and 6 deletions

View file

@ -19,9 +19,11 @@ use libimagstore::store::FileLockEntry;
use libimagstore::store::Store; use libimagstore::store::Store;
use libimagstore::storeid::StoreId; use libimagstore::storeid::StoreId;
use libimagstore::storeid::IntoStoreId; use libimagstore::storeid::IntoStoreId;
use libimagutil::debug_result::*;
use error::LinkError as LE; use error::LinkError as LE;
use error::LinkErrorKind as LEK; use error::LinkErrorKind as LEK;
use error::MapErrInto;
use result::Result; use result::Result;
use internal::InternalLinker; use internal::InternalLinker;
use module_path::ModuleEntryPath; 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 // retrieve the file from the store, which implicitely creates the entry if it does not
// exist // exist
let file = store.retrieve(file_id.clone()); let mut file = try!(store
if file.is_err() { .retrieve(file_id.clone())
debug!("Failed to create or retrieve an file for this link '{:?}'", link); .map_err_into(LEK::StoreWriteError)
return Err(LE::new(LEK::StoreWriteError, Some(Box::new(file.unwrap_err())))); .map_dbg_err(|_| {
} format!("Failed to create or retrieve an file for this link '{:?}'", link)
let mut file = file.unwrap(); }));
debug!("Generating header content!"); debug!("Generating header content!");
{ {

View file

@ -7,6 +7,7 @@ use libimagstore::store::Result as StoreResult;
use libimagerror::into::IntoError; use libimagerror::into::IntoError;
use error::LinkErrorKind as LEK; use error::LinkErrorKind as LEK;
use error::MapErrInto;
use result::Result; use result::Result;
use toml::Value; use toml::Value;