use std::fmt::{self, Display, Formatter};
use self::SettingError::{UnknownChoice, UnknownSetting, WrongType};
#[allow(missing_docs)]
#[derive(Debug, PartialEq)]
pub enum SettingError {
UnknownChoice {
actual: String,
expected: Vec<&'static str>
},
UnknownSetting(String),
WrongType {
actual: String,
expected: String,
},
}
impl Display for SettingError {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
match *self {
UnknownChoice { ref actual, ref expected } =>
write!(formatter, "unknown choice {}, expecting one of: {}", actual, expected.join(", ")),
UnknownSetting(ref name) =>
write!(formatter, "no setting named {}", name),
WrongType { ref actual, ref expected } =>
write!(formatter, "wrong value type: expecting {}, but found {}", expected, actual),
}
}
}