use std::fmt;
pub type EnigmaResult<T> = Result<T, EnigmaError>;
#[derive(Debug)]
pub enum EnigmaError {
InvalidConfiguration(String),
InvalidState(String),
ComponentError(String),
SteppingError(String),
}
impl fmt::Display for EnigmaError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
EnigmaError::InvalidConfiguration(msg) => {
write!(f, "invalid configuration: {msg}")
}
EnigmaError::InvalidState(msg) => {
write!(f, "invalid state: {msg}")
}
EnigmaError::ComponentError(msg) => {
write!(f, "component error: {msg}")
}
EnigmaError::SteppingError(msg) => {
write!(f, "stepping error: {msg}")
}
}
}
}
impl std::error::Error for EnigmaError {}