xml: Some work on errors

This commit is contained in:
Lennart
2025-02-06 14:06:17 +01:00
parent 9b6ad4eb39
commit 6caa04a516
9 changed files with 37 additions and 33 deletions

View File

@@ -30,10 +30,12 @@ impl rustical_xml::ValueDeserialize for CalendarObjectType {
"VEVENT" => Ok(Self::Event),
"VTODO" => Ok(Self::Todo),
"VJOURNAL" => Ok(Self::Journal),
_ => Err(rustical_xml::XmlError::Other(format!(
"Invalid value '{}', must be VEVENT, VTODO, or VJOURNAL",
val
))),
_ => Err(rustical_xml::XmlError::InvalidValue(
rustical_xml::ParseValueError::Other(format!(
"Invalid value '{}', must be VEVENT, VTODO, or VJOURNAL",
val
)),
)),
}
}
}

View File

@@ -30,7 +30,9 @@ impl ValueDeserialize for UtcDateTime {
Ok(Self(
NaiveDateTime::parse_from_str(&input, UTC_DATE_TIME)
.map_err(|_| {
rustical_xml::XmlError::Other("Could not parse as UTC timestamp".to_owned())
rustical_xml::XmlError::InvalidValue(rustical_xml::ParseValueError::Other(
"Could not parse as UTC timestamp".to_owned(),
))
})?
.and_utc(),
))