Add some more error types to be more specific about what happened
This commit is contained in:
parent
9f8a648600
commit
22052ba9f0
2 changed files with 8 additions and 2 deletions
|
@ -20,6 +20,7 @@ pub enum StoreErrorKind {
|
|||
IoError,
|
||||
StorePathExists,
|
||||
StorePathCreate,
|
||||
LockError,
|
||||
LockPoisoned,
|
||||
EntryAlreadyBorrowed,
|
||||
EntryAlreadyExists,
|
||||
|
@ -29,6 +30,7 @@ pub enum StoreErrorKind {
|
|||
HeaderKeyNotFound,
|
||||
HeaderTypeFailure,
|
||||
HookRegisterError,
|
||||
AspectNameNotFoundError,
|
||||
HookExecutionError,
|
||||
PreHookExecuteError,
|
||||
PostHookExecuteError,
|
||||
|
@ -50,6 +52,7 @@ fn store_error_type_as_str(e: &StoreErrorKind) -> &'static str {
|
|||
&StoreErrorKind::IoError => "File Error",
|
||||
&StoreErrorKind::StorePathExists => "Store path exists",
|
||||
&StoreErrorKind::StorePathCreate => "Store path create",
|
||||
&StoreErrorKind::LockError => "Error locking datastructure",
|
||||
&StoreErrorKind::LockPoisoned
|
||||
=> "The internal Store Lock has been poisoned",
|
||||
&StoreErrorKind::EntryAlreadyBorrowed => "Entry is already borrowed",
|
||||
|
@ -60,6 +63,7 @@ fn store_error_type_as_str(e: &StoreErrorKind) -> &'static str {
|
|||
&StoreErrorKind::HeaderKeyNotFound => "Header Key not found",
|
||||
&StoreErrorKind::HeaderTypeFailure => "Header type is wrong",
|
||||
&StoreErrorKind::HookRegisterError => "Hook register error",
|
||||
&StoreErrorKind::AspectNameNotFoundError => "Aspect name not found",
|
||||
&StoreErrorKind::HookExecutionError => "Hook execution error",
|
||||
&StoreErrorKind::PreHookExecuteError => "Pre-Hook execution error",
|
||||
&StoreErrorKind::PostHookExecuteError => "Post-Hook execution error",
|
||||
|
|
|
@ -436,7 +436,7 @@ impl Store {
|
|||
let guard = guard
|
||||
.deref()
|
||||
.lock()
|
||||
.map_err(|_| StoreError::new(StoreErrorKind::HookRegisterError, None));
|
||||
.map_err(|_| StoreError::new(StoreErrorKind::LockError, None));
|
||||
|
||||
if guard.is_err() {
|
||||
return Err(StoreError::new(StoreErrorKind::HookRegisterError,
|
||||
|
@ -450,7 +450,9 @@ impl Store {
|
|||
return Ok(());
|
||||
}
|
||||
}
|
||||
return Err(StoreError::new(StoreErrorKind::HookRegisterError, None));
|
||||
|
||||
let annfe = StoreError::new(StoreErrorKind::AspectNameNotFoundError, None);
|
||||
return Err(StoreError::new(StoreErrorKind::HookRegisterError, Some(Box::new(annfe))));
|
||||
}
|
||||
|
||||
fn get_config_for_hook(&self, name: &str) -> Option<&Value> {
|
||||
|
|
Loading…
Reference in a new issue