use core::fmt;
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum FlockfileError {
Toml(String),
Yaml(String),
Json(String),
Json5(String),
NoApps,
UnknownKeys {
keys: Vec<String>,
},
}
impl fmt::Display for FlockfileError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Toml(m) => write!(f, "invalid TOML Flockfile: {m}"),
Self::Yaml(m) => write!(f, "invalid YAML Flockfile: {m}"),
Self::Json(m) => write!(f, "invalid JSON Flockfile: {m}"),
Self::Json5(m) => write!(f, "invalid JSON5 Flockfile: {m}"),
Self::NoApps => f.write_str("Flockfile declares no apps"),
Self::UnknownKeys { keys } => {
write!(f, "Flockfile names unrecognized key")?;
if keys.len() != 1 {
f.write_str("s")?;
}
write!(f, ": {}", keys.join(", "))
}
}
}
}
impl core::error::Error for FlockfileError {}