Simplify error printing if config value fetching failed
This commit is contained in:
parent
4e2a980599
commit
f86b450cfa
3 changed files with 6 additions and 13 deletions
|
@ -103,17 +103,12 @@ impl StoreIdAccessor for CreateHook {
|
|||
.map_into_hook_error()
|
||||
);
|
||||
|
||||
let cfg = try!(
|
||||
self.runtime
|
||||
.config_value_or_err()
|
||||
.map_dbg_err_str("[GIT CREATE HOOK]: Couldn't get Value object from config")
|
||||
);
|
||||
|
||||
debug!("[GIT CREATE HOOK]: Ensuring branch checkout");
|
||||
try!(self.runtime.ensure_cfg_branch_is_checked_out());
|
||||
debug!("[GIT CREATE HOOK]: Branch checked out");
|
||||
|
||||
let action = StoreAction::Create;
|
||||
let cfg = try!(self.runtime.config_value_or_err(&action));
|
||||
let repo = try!(fetch_repo(&self.runtime, &action));
|
||||
let mut index = try!(fetch_index(repo, &action));
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ impl Runtime {
|
|||
self.config.is_some()
|
||||
}
|
||||
|
||||
pub fn config_value_or_err(&self) -> HookResult<&Value> {
|
||||
pub fn config_value_or_err(&self, action: &StoreAction) -> HookResult<&Value> {
|
||||
self.config
|
||||
.as_ref()
|
||||
.ok_or(GHEK::NoConfigError.into_error())
|
||||
|
@ -55,6 +55,9 @@ impl Runtime {
|
|||
.map_err(Box::new)
|
||||
.map_err(|e| HEK::HookExecutionError.into_error_with_cause(e))
|
||||
.map_err(|mut e| e.with_custom_data(CustomData::default().aborting(false)))
|
||||
.map_dbg_err(|_| {
|
||||
format!("[GIT {} HOOK]: Couldn't get Value object from config", action.uppercase())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn repository(&self) -> HookResult<&Repository> {
|
||||
|
|
|
@ -91,13 +91,8 @@ impl StoreIdAccessor for UpdateHook {
|
|||
|
||||
debug!("[GIT UPDATE HOOK]: {:?}", id);
|
||||
|
||||
let cfg = try!(
|
||||
self.runtime
|
||||
.config_value_or_err()
|
||||
.map_dbg_err_str("[GIT UPDATE HOOK]: Couldn't get Value object from config")
|
||||
);
|
||||
|
||||
let action = StoreAction::Update;
|
||||
let cfg = try!(self.runtime.config_value_or_err(&action));
|
||||
let repo = try!(fetch_repo(&self.runtime, &action));
|
||||
let mut index = try!(fetch_index(repo, &action));
|
||||
|
||||
|
|
Loading…
Reference in a new issue