2024-03-05 15:07:47 +00:00
|
|
|
use quick_xml::events::attributes::AttrError;
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum ParsingError {
|
2024-03-06 22:24:54 +00:00
|
|
|
Recoverable,
|
2024-03-05 18:06:04 +00:00
|
|
|
MissingChild,
|
2024-03-08 17:23:23 +00:00
|
|
|
MissingAttribute,
|
2024-03-05 15:07:47 +00:00
|
|
|
NamespacePrefixAlreadyUsed,
|
|
|
|
WrongToken,
|
|
|
|
TagNotFound,
|
2024-03-06 15:09:20 +00:00
|
|
|
InvalidValue,
|
2024-03-06 09:12:02 +00:00
|
|
|
Utf8Error(std::str::Utf8Error),
|
2024-03-05 15:07:47 +00:00
|
|
|
QuickXml(quick_xml::Error),
|
2024-03-06 11:42:27 +00:00
|
|
|
Chrono(chrono::format::ParseError),
|
|
|
|
Int(std::num::ParseIntError),
|
2024-03-05 15:07:47 +00:00
|
|
|
Eof
|
|
|
|
}
|
|
|
|
impl From<AttrError> for ParsingError {
|
|
|
|
fn from(value: AttrError) -> Self {
|
|
|
|
Self::QuickXml(value.into())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl From<quick_xml::Error> for ParsingError {
|
|
|
|
fn from(value: quick_xml::Error) -> Self {
|
|
|
|
Self::QuickXml(value)
|
|
|
|
}
|
|
|
|
}
|
2024-03-06 09:12:02 +00:00
|
|
|
impl From<std::str::Utf8Error> for ParsingError {
|
|
|
|
fn from(value: std::str::Utf8Error) -> Self {
|
|
|
|
Self::Utf8Error(value)
|
|
|
|
}
|
|
|
|
}
|
2024-03-06 11:42:27 +00:00
|
|
|
impl From<chrono::format::ParseError> for ParsingError {
|
|
|
|
fn from(value: chrono::format::ParseError) -> Self {
|
|
|
|
Self::Chrono(value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<std::num::ParseIntError> for ParsingError {
|
|
|
|
fn from(value: std::num::ParseIntError) -> Self {
|
|
|
|
Self::Int(value)
|
|
|
|
}
|
|
|
|
}
|