2016-03-04 15:43:01 +00:00
|
|
|
use std::error::Error;
|
|
|
|
use std::fmt::Error as FmtError;
|
|
|
|
use std::fmt::{Display, Formatter};
|
|
|
|
use std::convert::Into;
|
|
|
|
|
2016-05-15 14:41:25 +00:00
|
|
|
generate_error_types!(HookError, HookErrorKind,
|
|
|
|
HookExecutionError => "Hook exec error",
|
|
|
|
AccessTypeViolation => "Hook access type violation"
|
|
|
|
);
|
2016-03-04 15:43:01 +00:00
|
|
|
|
|
|
|
pub trait IntoHookError {
|
|
|
|
fn into_hookerror(self) -> HookError;
|
|
|
|
fn into_hookerror_with_cause(self, cause: Box<Error>) -> HookError;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<HookError> for HookErrorKind {
|
|
|
|
|
|
|
|
fn into(self) -> HookError {
|
|
|
|
HookError::new(self, None)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<HookError> for (HookErrorKind, Box<Error>) {
|
|
|
|
|
|
|
|
fn into(self) -> HookError {
|
|
|
|
HookError::new(self.0, Some(self.1))
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|