rustical_xml/
error.rs

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