rustical_xml/
error.rs

1use std::string::FromUtf8Error;
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum XmlError {
7    // Syntactic errors
8    #[error(transparent)]
9    QuickXmlError(#[from] quick_xml::Error),
10    #[error(transparent)]
11    QuickXmlEncodingError(#[from] quick_xml::encoding::EncodingError),
12    #[error(transparent)]
13    QuickXmlAttrError(#[from] quick_xml::events::attributes::AttrError),
14    #[error(transparent)]
15    FromUtf8Error(#[from] FromUtf8Error),
16    #[error("End of file, expected closing tags")]
17    Eof,
18    #[error("Unsupported xml event: {0}")]
19    UnsupportedEvent(&'static str),
20
21    // Semantic errors
22    #[error("Invalid tag [{0}]{1}. Expected [{2}]{3}")]
23    InvalidTag(String, String, String, String),
24    #[error("Missing field {0}")]
25    MissingField(&'static str),
26    #[error("Invalid variant: {0}")]
27    InvalidVariant(String),
28    #[error("Invalid field name in {0}: {1}")]
29    InvalidFieldName(&'static str, String),
30    #[error(transparent)]
31    InvalidValue(#[from] crate::value::ParseValueError),
32}