use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("unrecognized config format {0:?}: expected one of toml, json, yaml, yml")]
UnknownFormat(String),
#[error("invalid TOML config: {0}")]
Toml(#[from] toml::de::Error),
#[error("could not write TOML config: {0}")]
TomlEncode(#[from] toml::ser::Error),
#[error("invalid JSON config: {0}")]
Json(#[from] serde_json::Error),
#[error("invalid YAML config: {0}")]
Yaml(#[from] serde_norway::Error),
#[error("config version {found} is not supported: this build understands version {expected}")]
UnsupportedVersion {
found: u32,
expected: u32,
},
#[error("invalid config at {at}: {why}")]
Invalid {
at: String,
why: String,
},
#[error(
"this .gitignore is not in canonical form, so importing it would not \
round-trip: line {line} would be rewritten from {expected:?} to \
{actual:?}. Only comments and blank lines differ; the patterns git \
acts on are unchanged. Run `ign fmt` to normalize the file, then \
import it again."
)]
NotCanonical {
line: usize,
expected: String,
actual: String,
},
}