use core::{
error::Error,
fmt::{self, Display, Formatter},
str::Utf8Error,
};
use quick_xml::{encoding::EncodingError, escape::EscapeError};
#[derive(Debug)]
pub enum SitemapError {
Utf8(Utf8Error),
Xml(quick_xml::Error),
}
impl Error for SitemapError {}
impl Display for SitemapError {
fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
match self {
Self::Xml(error) => write!(formatter, "{error}"),
Self::Utf8(error) => write!(formatter, "{error}"),
}
}
}
impl From<quick_xml::Error> for SitemapError {
fn from(error: quick_xml::Error) -> Self {
Self::Xml(error)
}
}
impl From<Utf8Error> for SitemapError {
fn from(error: Utf8Error) -> Self {
Self::Utf8(error)
}
}
impl From<EncodingError> for SitemapError {
fn from(error: EncodingError) -> Self {
Self::Xml(error.into())
}
}
impl From<EscapeError> for SitemapError {
fn from(error: EscapeError) -> Self {
Self::Xml(error.into())
}
}