Add IntoHookError for convenience function map_into_hook_error()

This commit is contained in:
Matthias Beyer 2016-09-07 18:36:32 +02:00
parent ca94a6cb7c
commit ec1b5f7e8b
1 changed files with 12 additions and 0 deletions

View File

@ -59,6 +59,18 @@ impl From<Git2Error> for GitHookError {
}
pub trait MapIntoHookError<T> {
fn map_into_hook_error(self) -> Result<T, HE>;
}
impl<T> MapIntoHookError<T> for Result<T, GitHookError> {
fn map_into_hook_error(self) -> Result<T, HE> {
self.map_err(|e| HE::new(HEK::HookExecutionError, Some(Box::new(e))))
}
}
pub use self::error::GitHookError;
pub use self::error::GitHookErrorKind;
pub use self::error::MapErrInto;