use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum PercentDecodeError {
InvalidEscape {
index: usize,
},
InvalidUtf8,
}
impl fmt::Display for PercentDecodeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidEscape { index } => {
write!(f, "invalid percent escape at byte {index}")
}
Self::InvalidUtf8 => write!(f, "decoded bytes are not valid UTF-8"),
}
}
}
impl std::error::Error for PercentDecodeError {}
#[cfg(test)]
#[path = "percent_decode_error.test.rs"]
mod tests;