hard_xml/
xml_extended_error.rs

1/// More Error Cases.
2///
3/// This is a hack because `XmlError` is not open to extension.
4///
5/// TODO(v2): Merge these errors into `XmlError`.
6#[derive(Debug)]
7#[non_exhaustive]
8pub enum XmlExtendedError {
9    DuplicateAttribute(std::borrow::Cow<'static, str>),
10    DuplicateElement(std::borrow::Cow<'static, str>),
11}
12
13impl std::error::Error for XmlExtendedError {}
14
15impl std::fmt::Display for XmlExtendedError {
16    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17        match self {
18            XmlExtendedError::DuplicateAttribute(attr) => write!(f, "Duplicate attribute {:?}", attr),
19            XmlExtendedError::DuplicateElement(name) => write!(f, "Duplicate element <{}>", name),
20        }
21    }
22}