diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-10-17 13:43:45 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-10-17 17:48:22 +0200 |
commit | dd4f0c7586aa806dfca3f71289667eb4cd8a6506 (patch) | |
tree | 5544dcc18f954ea58de555b4a59921d6f6d2a8ae | |
parent | 44f78ae50a71be38d2591d10370e5826b25bf0aa (diff) |
Raise error when reading links failed, rather than assuming `1`
-rw-r--r-- | libimagstorestdhook/src/denylinkeddelete.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/libimagstorestdhook/src/denylinkeddelete.rs b/libimagstorestdhook/src/denylinkeddelete.rs index 6a24647e..98f3a01a 100644 --- a/libimagstorestdhook/src/denylinkeddelete.rs +++ b/libimagstorestdhook/src/denylinkeddelete.rs @@ -32,7 +32,8 @@ use libimagentrylink::internal::InternalLinker; mod error { generate_error_imports!(); generate_error_types!(NoLinksLeftCheckerHookError, NoLinksLeftCheckerHookErrorKind, - LinksLeft => "The entry has links and therefor cannot be deleted." + ReadInternalLinksError => "Error while reading internal links of entry", + LinksLeft => "The entry has links and therefor cannot be deleted." ); } use self::error::NoLinksLeftCheckerHookErrorKind as NLLCHEK; @@ -86,21 +87,17 @@ impl HookDataAccessorProvider for DenyDeletionOfLinkedEntriesHook { impl NonMutableHookDataAccessor for DenyDeletionOfLinkedEntriesHook { fn access(&self, fle: &FileLockEntry) -> HookResult<()> { - use libimagutil::warn_result::*; - use libimagutil::debug_result::*; - use libimagerror::trace::MapErrTrace; use libimagerror::into::IntoError; + use self::error::MapErrInto; debug!("[NO LINKS LEFT CHECKER HOOK] {:?}", fle.get_location()); - let n = fle + let n = try!(fle .get_internal_links() .map(|i| i.count()) - .map_warn_err_str("[NO LINKS LEFT CHECKER HOOK]: Cannot get internal links") - .map_warn_err_str("[NO LINKS LEFT CHECKER HOOK]: Assuming 1 to automatically abort") - .map_dbg_err_str("[NO LINKS LEFT CHECKER HOOK]: Printing trace now") - .map_err_trace() - .unwrap_or(1); + .map_err_into(NLLCHEK::ReadInternalLinksError) + .map_err(Box::new) + .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e))); if n > 0 { Err(NLLCHEK::LinksLeft.into_error()) |