Add HookErrorKind enums for Pre and Post errors

This commit is contained in:
Matthias Beyer 2016-02-17 19:17:51 +01:00
parent d7733aa13a
commit 57831dceb0

View file

@ -94,15 +94,39 @@ pub mod error {
use std::fmt::Error as FmtError; use std::fmt::Error as FmtError;
use std::clone::Clone; use std::clone::Clone;
use std::fmt::{Display, Formatter}; use std::fmt::{Display, Formatter};
use std::convert::Into;
/** /**
* Kind of error * Kind of error
*/ */
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug)]
pub enum HookErrorKind { pub enum HookErrorKind {
Pre(PreHookErrorKind),
Post(PostHookErrorKind)
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum PreHookErrorKind {
// ... // ...
} }
impl Into<HookErrorKind> for PreHookErrorKind {
fn into(self) -> HookErrorKind {
HookErrorKind::Pre(self)
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum PostHookErrorKind {
// ...
}
impl Into<HookErrorKind> for PostHookErrorKind {
fn into(self) -> HookErrorKind {
HookErrorKind::Post(self)
}
}
fn hook_error_type_as_str(e: &HookErrorKind) -> &'static str { fn hook_error_type_as_str(e: &HookErrorKind) -> &'static str {
match e { match e {
_ => "", _ => "",