Merge pull request #746 from matthiasbeyer/libimagstorestdhook/git-refactor-error-mapping
libimagstorestdhook/git: refactor error mapping
This commit is contained in:
commit
614b90e643
2 changed files with 8 additions and 19 deletions
|
@ -493,10 +493,7 @@ impl Store {
|
||||||
|
|
||||||
/// Return the `FileLockEntry` and write to disk
|
/// Return the `FileLockEntry` and write to disk
|
||||||
pub fn update<'a>(&'a self, mut entry: FileLockEntry<'a>) -> Result<()> {
|
pub fn update<'a>(&'a self, mut entry: FileLockEntry<'a>) -> Result<()> {
|
||||||
if let Err(e) = self._update(&mut entry) {
|
self._update(&mut entry).map_err_into(SEK::UpdateCallError)
|
||||||
return Err(e).map_err_into(SEK::UpdateCallError);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Internal method to write to the filesystem store.
|
/// Internal method to write to the filesystem store.
|
||||||
|
@ -505,12 +502,11 @@ impl Store {
|
||||||
/// This method assumes that entry is dropped _right after_ the call, hence
|
/// This method assumes that entry is dropped _right after_ the call, hence
|
||||||
/// it is not public.
|
/// it is not public.
|
||||||
fn _update<'a>(&'a self, entry: &mut FileLockEntry<'a>) -> Result<()> {
|
fn _update<'a>(&'a self, entry: &mut FileLockEntry<'a>) -> Result<()> {
|
||||||
if let Err(e) = self.execute_hooks_for_mut_file(self.pre_update_aspects.clone(), entry) {
|
let _ = try!(self.execute_hooks_for_mut_file(self.pre_update_aspects.clone(), entry)
|
||||||
return Err(e)
|
|
||||||
.map_err_into(SEK::PreHookExecuteError)
|
.map_err_into(SEK::PreHookExecuteError)
|
||||||
.map_err_into(SEK::HookExecutionError)
|
.map_err_into(SEK::HookExecutionError)
|
||||||
.map_err_into(SEK::UpdateCallError);
|
.map_err_into(SEK::UpdateCallError)
|
||||||
}
|
);
|
||||||
|
|
||||||
let mut hsmap = match self.entries.write() {
|
let mut hsmap = match self.entries.write() {
|
||||||
Err(_) => return Err(SE::new(SEK::LockPoisoned, None)),
|
Err(_) => return Err(SE::new(SEK::LockPoisoned, None)),
|
||||||
|
|
|
@ -4,7 +4,7 @@ use git2::{Index, Repository};
|
||||||
use toml::Value;
|
use toml::Value;
|
||||||
|
|
||||||
use libimagerror::into::IntoError;
|
use libimagerror::into::IntoError;
|
||||||
use libimagerror::trace::trace_error;
|
use libimagerror::trace::{MapErrTrace, trace_error};
|
||||||
use libimagstore::hook::error::CustomData;
|
use libimagstore::hook::error::CustomData;
|
||||||
use libimagstore::hook::error::HookErrorKind as HEK;
|
use libimagstore::hook::error::HookErrorKind as HEK;
|
||||||
use libimagstore::hook::result::HookResult;
|
use libimagstore::hook::result::HookResult;
|
||||||
|
@ -31,14 +31,7 @@ impl Runtime {
|
||||||
/// returns a `Runtime` object that does _not_ contain a `Repository`.
|
/// returns a `Runtime` object that does _not_ contain a `Repository`.
|
||||||
pub fn new(storepath: &PathBuf) -> Runtime {
|
pub fn new(storepath: &PathBuf) -> Runtime {
|
||||||
Runtime {
|
Runtime {
|
||||||
repository: match Repository::open(storepath) {
|
repository: Repository::open(storepath).map_err_trace().ok(),
|
||||||
Ok(r) => Some(r),
|
|
||||||
Err(e) => {
|
|
||||||
trace_error(&e);
|
|
||||||
None
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
config: None,
|
config: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue