Add error kind and impl From<Git2Error> for HE

This commit is contained in:
Matthias Beyer 2016-07-27 13:10:54 +02:00
parent 204ebc884c
commit e5a066ed0b

View file

@ -1,3 +1,5 @@
use git2::Error as Git2Error;
use libimagstore::hook::error::HookError as HE; use libimagstore::hook::error::HookError as HE;
use libimagstore::hook::error::HookErrorKind as HEK; use libimagstore::hook::error::HookErrorKind as HEK;
use libimagstore::hook::result::HookResult; use libimagstore::hook::result::HookResult;
@ -8,6 +10,7 @@ generate_error_module!(
NoConfigError => "No Configuration", NoConfigError => "No Configuration",
ConfigTypeError => "Configuration value type wrong", ConfigTypeError => "Configuration value type wrong",
RuntimeInformationSetupError => "Couldn't setup runtime information for git hook", RuntimeInformationSetupError => "Couldn't setup runtime information for git hook",
RepositoryBackendError => "Error in the git library",
RepositoryError => "Error while interacting with git repository", RepositoryError => "Error while interacting with git repository",
RepositoryBranchError => "Error while interacting with git branch(es)", RepositoryBranchError => "Error while interacting with git branch(es)",
RepositoryBranchNameFetchingError => "Error while fetching branch name", RepositoryBranchNameFetchingError => "Error while fetching branch name",
@ -41,6 +44,14 @@ impl From<GitHookError> for HE {
} }
impl From<Git2Error> for GitHookError {
fn from(ge: Git2Error) -> GitHookError {
GitHookError::new(GitHookErrorKind::RepositoryBackendError, Some(Box::new(ge)))
}
}
pub use self::error::GitHookError; pub use self::error::GitHookError;
pub use self::error::GitHookErrorKind; pub use self::error::GitHookErrorKind;
pub use self::error::MapErrInto; pub use self::error::MapErrInto;