use thiserror::Error;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum ParseCountryError {
#[error("not a recognized ISO 3166-1 alpha-2 country code")]
InvalidAlpha2,
#[error("not a recognized ISO 3166-1 alpha-3 country code")]
InvalidAlpha3,
#[error("not a recognized ISO 3166-1 numeric country code")]
InvalidNumeric,
#[error("numeric value out of range (expected 0..=999)")]
NumericOutOfRange,
#[error("input length {got} does not match expected {expected}")]
InvalidLength {
expected: u8,
got: usize,
},
#[error("input contains non-ASCII bytes")]
NonAscii,
#[error("input is not a valid unsigned integer")]
NotAnInteger,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum ParseSubdivisionError {
#[error("subdivision code is missing the '-' separator at position 2")]
MissingSeparator,
#[error("subdivision code parent is not a valid ISO 3166-1 alpha-2 code")]
InvalidParent,
#[error("not a recognized ISO 3166-2 subdivision code")]
UnknownSubdivision,
#[error("input contains non-ASCII bytes")]
NonAscii,
#[error("subdivision code length {got} is out of range (expected 4..=6)")]
InvalidLength {
got: usize,
},
}