1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug, Error)]
10pub enum Error {
11 #[error("Failed to parse XML: {0}")]
13 Xml(quick_xml::Error),
14 #[error("Expected start element <{0}>, found <{1}>")]
16 WrongStart(String, String),
17 #[error("Expected end element </{0}>, found </{1}>")]
19 WrongEnd(String, String),
20 #[error("Missing start element")]
22 MissingStart,
23 #[error("Missing attribute {0}")]
25 MissingAttribute(String),
26 #[error("Missing child <{0}>")]
28 MissingChild(String),
29 #[error("Missing element text")]
31 MissingText,
32 #[error("Found multiple child elements <{0}>, but only expected one")]
34 DoubleChild(String),
35 #[error("Element contains multiple text events")]
37 DoubleText,
38 #[error("Found unexpected attribute {0}")]
40 UnexpectedAttribute(String),
41 #[error("Found unexpected child element <{0}>")]
43 UnexpectedChild(String),
44 #[error("Found unexpected text")]
46 UnexpectedText,
47 #[error("Error deserializing element <{0}>: {1}")]
49 InnerDeserialiaztionError(String, Box<Error>),
50 #[error("Deserialization error: {0}")]
52 Deserialization(String),
53}
54
55impl<T> From<T> for Error
56where
57 T: Into<quick_xml::Error>,
58{
59 fn from(e: T) -> Self {
60 Self::Xml(e.into())
61 }
62}