use core::fmt;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ParseArrayError {
UnexpectedEnd,
InvalidElement {
c: char,
or_end: bool,
},
ExpectedCommaOrEnd(char),
TrailingComma,
}
impl fmt::Display for ParseArrayError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::UnexpectedEnd => write!(f, "Unexpected end of JSON array!"),
Self::InvalidElement { c, or_end: true } => write!(
f,
"Invalid character ({c}) in JSON array (expected an element or an end, ']')!"
),
Self::InvalidElement { c, or_end: false } => write!(
f,
"Invalid character ({c}) in JSON array (expected an element)!"
),
Self::ExpectedCommaOrEnd(c) => write!(
f,
"Invalid character ({c}) in JSON array (expected a comma or an end, ']')"
),
Self::TrailingComma => write!(f, "Trailing comma in JSON array!"),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for ParseArrayError {}