tree_xml/
error.rs

1use thiserror::Error;
2
3use std::str::Utf8Error;
4
5use quick_xml::events::attributes::AttrError;
6use quick_xml::Error as XmlError;
7
8pub type Result<T> = core::result::Result<T, Error>;
9
10#[derive(Error, Debug)]
11pub enum Error {
12    #[error("IO error kind: {0}")]
13    IOErrorKind(std::io::ErrorKind),
14    #[error("IO error: {0}")]
15    IOError(#[from] std::io::Error),
16    #[error("Error from the quick-xml crate: {0}")]
17    XmlError(#[from] XmlError),
18    #[error("UTF8 error while parsing to node: {0}")]
19    Utf8Error(#[from] Utf8Error),
20    #[error("Attribute error: {0}")]
21    AttributeXmlError(#[from] AttrError),
22    #[error("End of XML file")]
23    Eof,
24    #[error("Parse node error: {0}")]
25    ParseNodeError(#[from] ParseNodeError),
26}
27
28#[derive(Debug, Error)]
29pub enum ParseNodeError {
30    #[error("Expected {0} but found {1}")]
31    WrongName(String, String),
32    #[error("No child <{0}> found in parent <{1}>")]
33    MissingChild(String, String),
34    #[error("No attribute with key '{0}' found in <{1}>")]
35    MissingAttribute(String, String),
36}