Merge pull request #538 from jsirois/jsirois/cleanups/err_or_else

Cleanup `HookError` tracing logic.
This commit is contained in:
Matthias Beyer 2016-07-15 11:19:11 +02:00 committed by GitHub
commit 6a4c620c2c

View file

@ -51,19 +51,7 @@ impl StoreIdAccessor for Aspect {
&HDA::StoreIdAccess(accessor) => accessor.access(id), &HDA::StoreIdAccess(accessor) => accessor.access(id),
_ => unreachable!(), _ => unreachable!(),
}; };
trace_hook_errors(res)
match res {
Ok(res) => Ok(res),
Err(e) => {
if !e.is_aborting() {
trace_error(&e);
// ignore error if it is not aborting, as we printed it already
Ok(())
} else {
Err(e)
}
}
}
}) })
} }
} }
@ -94,19 +82,7 @@ impl MutableHookDataAccessor for Aspect {
&HDA::NonMutableAccess(ref accessor) => accessor.access(fle), &HDA::NonMutableAccess(ref accessor) => accessor.access(fle),
_ => unreachable!(), _ => unreachable!(),
}; };
trace_hook_errors(res)
match res {
Ok(res) => Ok(res),
Err(e) => {
if !e.is_aborting() {
trace_error(&e);
// ignore error if it is not aborting, as we printed it already
Ok(())
} else {
Err(e)
}
}
}
}) })
} }
} }
@ -123,20 +99,20 @@ impl NonMutableHookDataAccessor for Aspect {
&HDA::NonMutableAccess(accessor) => accessor.access(fle), &HDA::NonMutableAccess(accessor) => accessor.access(fle),
_ => unreachable!(), _ => unreachable!(),
}; };
trace_hook_errors(res)
match res {
Ok(res) => Ok(res),
Err(e) => {
if !e.is_aborting() {
trace_error(&e);
// ignore error if it is not aborting, as we printed it already
Ok(())
} else {
Err(e)
}
}
}
}) })
} }
} }
fn trace_hook_errors(res: HookResult<()>) -> HookResult<()> {
res.or_else(|e| {
if !e.is_aborting() {
trace_error(&e);
// ignore error if it is not aborting, as we printed it already
Ok(())
} else {
Err(e)
}
})
}