From 1a43ce5ac7033c148f64a033f2b1d335e95e11d5 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Fri, 8 Mar 2024 08:17:03 +0100 Subject: WIP refactor --- aero-dav/src/error.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 aero-dav/src/error.rs (limited to 'aero-dav/src/error.rs') diff --git a/aero-dav/src/error.rs b/aero-dav/src/error.rs new file mode 100644 index 0000000..78c6d6b --- /dev/null +++ b/aero-dav/src/error.rs @@ -0,0 +1,42 @@ +use quick_xml::events::attributes::AttrError; + +#[derive(Debug)] +pub enum ParsingError { + Recoverable, + MissingChild, + NamespacePrefixAlreadyUsed, + WrongToken, + TagNotFound, + InvalidValue, + Utf8Error(std::str::Utf8Error), + QuickXml(quick_xml::Error), + Chrono(chrono::format::ParseError), + Int(std::num::ParseIntError), + Eof +} +impl From for ParsingError { + fn from(value: AttrError) -> Self { + Self::QuickXml(value.into()) + } +} +impl From for ParsingError { + fn from(value: quick_xml::Error) -> Self { + Self::QuickXml(value) + } +} +impl From for ParsingError { + fn from(value: std::str::Utf8Error) -> Self { + Self::Utf8Error(value) + } +} +impl From for ParsingError { + fn from(value: chrono::format::ParseError) -> Self { + Self::Chrono(value) + } +} + +impl From for ParsingError { + fn from(value: std::num::ParseIntError) -> Self { + Self::Int(value) + } +} -- cgit v1.2.3