Merge pull request #817 from matthiasbeyer/resolve-hidden-errs
Resolve hidden errs
This commit is contained in:
commit
0cd5aa475e
5 changed files with 21 additions and 13 deletions
|
@ -49,11 +49,16 @@ pub fn list(rt: &Runtime) {
|
|||
debug!("Iterator for listing: {:?}", es);
|
||||
|
||||
let es = es
|
||||
.filter_map(|a| a.map_dbg(|e| format!("Filtering: {:?}", e)).ok())
|
||||
.filter_map(|entry| {
|
||||
entry
|
||||
.map_dbg(|e| format!("Filtering: {:?}", e))
|
||||
.map_err_trace() // error tracing here
|
||||
.ok() // so we can ignore errors here
|
||||
})
|
||||
.map(|e| e.into());
|
||||
|
||||
CoreLister::new(&entry_to_location_listing_string)
|
||||
.list(es) // TODO: Do not ignore non-ok()s
|
||||
.list(es)
|
||||
.map_err_into(DEK::IOError)
|
||||
})
|
||||
.map_dbg_str("Ok")
|
||||
|
|
|
@ -50,12 +50,15 @@ impl Hasher for MailHasher {
|
|||
|
||||
let filter = subject_filter.or(from_filter).or(to_filter);
|
||||
|
||||
let s : String = mail.headers
|
||||
.iter()
|
||||
.filter(|item| filter.filter(item))
|
||||
.filter_map(|hdr| hdr.get_value().ok()) // TODO: Do not hide error here
|
||||
.collect::<Vec<String>>()
|
||||
.join("");
|
||||
let mut v = vec![];
|
||||
for hdr in mail.headers.iter().filter(|item| filter.filter(item)) {
|
||||
let s = try!(hdr.get_value()
|
||||
.map_err(Box::new)
|
||||
.map_err(|e| REK::RefHashingError.into_error_with_cause(e)));
|
||||
|
||||
v.push(s);
|
||||
}
|
||||
let s : String = v.join("");
|
||||
|
||||
self.defaulthasher.create_hash(pb, &mut s.as_bytes())
|
||||
})
|
||||
|
|
|
@ -23,6 +23,7 @@ generate_error_module!(
|
|||
StoreWriteError => "Store write error",
|
||||
IOError => "IO Error",
|
||||
UTF8Error => "UTF8 Error",
|
||||
StoreIdError => "Error with storeid",
|
||||
HeaderTypeError => "Header type error",
|
||||
HeaderFieldMissingError => "Header field missing error",
|
||||
HeaderFieldWriteError => "Header field cannot be written",
|
||||
|
|
|
@ -146,7 +146,7 @@ fn lister_fn(fle: FileLockEntry,
|
|||
is_changed,
|
||||
is_changed_content,
|
||||
is_changed_permiss,
|
||||
r.get_path_hash().unwrap_or_else(|| String::from("Cannot get hash")),
|
||||
r.get_path_hash().unwrap_or_else(|_| String::from("Cannot get hash")),
|
||||
r.get_location())
|
||||
})
|
||||
.map_err(|e| LEK::FormatError.into_error_with_cause(Box::new(e)))
|
||||
|
|
|
@ -34,7 +34,6 @@ use libimagstore::storeid::StoreId;
|
|||
use libimagstore::storeid::IntoStoreId;
|
||||
use libimagstore::store::Store;
|
||||
use libimagerror::into::IntoError;
|
||||
use libimagerror::trace::MapErrTrace;
|
||||
|
||||
use toml::Value;
|
||||
|
||||
|
@ -249,18 +248,18 @@ impl<'a> Ref<'a> {
|
|||
}
|
||||
|
||||
/// Get the hash from the path of the ref
|
||||
pub fn get_path_hash(&self) -> Option<String> {
|
||||
pub fn get_path_hash(&self) -> Result<String> {
|
||||
self.0
|
||||
.get_location()
|
||||
.clone()
|
||||
.into_pathbuf()
|
||||
.map_err_trace()
|
||||
.ok() // TODO: Hiding the error here is not so nice
|
||||
.map_err_into(REK::StoreIdError)
|
||||
.and_then(|pb| {
|
||||
pb.file_name()
|
||||
.and_then(|osstr| osstr.to_str())
|
||||
.and_then(|s| s.split("~").next())
|
||||
.map(String::from)
|
||||
.ok_or(REK::StoreIdError.into_error())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue