junit_parser/
errors.rs

1#![warn(missing_docs)]
2use thiserror::Error;
3
4/// Error enumerates all possible errors returned by this library.
5#[derive(Error, Debug)]
6pub enum Error {
7    /// Error while parsing XML
8    #[error("Error while parsing XML")]
9    XMLError(#[from] ::quick_xml::Error),
10    /// Error while converting f64 attribute
11    #[error("Error while converting f64 attribute")]
12    ParseFloatError(#[from] std::num::ParseFloatError),
13    /// Error while converting u64 attribute
14    #[error("Error while converting u64 attribute")]
15    ParseIntError(#[from] std::num::ParseIntError),
16    /// Error while converting bytes to Utf8
17    #[error("Error while converting bytes to Utf8")]
18    ParseUt8Error(#[from] std::str::Utf8Error),
19    /// Error parsing the `property` element: missing `name`
20    #[error("Missing `name` attribute in property")]
21    MissingPropertyName,
22    /// Error while parsing: unexpected end of file
23    #[error("Unexpected end of XML while parsing a {0} element")]
24    UnexpectedEndOfFile(String),
25}
26
27impl From<::quick_xml::events::attributes::AttrError> for Error {
28    #[inline]
29    /// Convert [`::quick_xml::events::attributes`] into [`Error::XMLError`]
30    fn from(err: ::quick_xml::events::attributes::AttrError) -> Error {
31        Error::XMLError(err.into())
32    }
33}
34
35impl From<::quick_xml::escape::EscapeError> for Error {
36    #[inline]
37    /// Convert [`::quick_xml::escape::EscapeError`] into [`Error::XMLError`]
38    fn from(err: ::quick_xml::escape::EscapeError) -> Error {
39        Error::XMLError(err.into())
40    }
41}