imag/libimagstore/src/hook/error.rs

32 lines
678 B
Rust
Raw Normal View History

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;
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))
}
}