1use std::{fmt, result};
15use std::error::Error;
16
17pub type Result<T> = result::Result<T, BaconError>;
18
19#[derive(Debug, PartialEq, Eq, Clone)]
20pub enum BaconError {
21 GeneralError(String),
22 CodecError(String),
23 SteganographerError(String),
24}
25
26impl fmt::Display for BaconError {
27 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
28 match self {
29 &BaconError::GeneralError(ref message) => write!(f, "{}", message),
30 &BaconError::CodecError(ref message) => write!(f, "{}", message),
31 &BaconError::SteganographerError(ref message) => write!(f, "{}", message),
32 }
33 }
34}
35
36impl Error for BaconError {
37 fn description(&self) -> &str {
38 match *self {
39 BaconError::GeneralError(_) => "A general error occured",
40 BaconError::CodecError(_) => "An error coming from a codec occured",
41 BaconError::SteganographerError(_) => "An error coming from a steganographer occured",
42 }
43 }
44}