store, store_sqlite: Refactor error typing

This commit is contained in:
Lennart
2024-10-28 17:10:03 +01:00
parent 925b26ea0f
commit cce3e260af
9 changed files with 75 additions and 106 deletions

View File

@@ -1,6 +1,6 @@
use crate::{
error::Error,
model::{AddressObject, Addressbook},
Error,
};
use async_trait::async_trait;

View File

@@ -11,8 +11,8 @@ pub enum Error {
InvalidData(String),
#[error(transparent)]
Other(#[from] anyhow::Error),
ParserError(#[from] ical::parser::ParserError),
#[error(transparent)]
ParserError(#[from] ical::parser::ParserError),
Other(#[from] anyhow::Error),
}

View File

@@ -130,9 +130,9 @@ impl CalDateTime {
return Ok(CalDateTime::OlsonTZ(datetime));
} else {
// This time does not exist because there's a gap in local time
return Err(Error::Other(anyhow!(
"Timestamp doesn't exist because of gap in local time"
)));
return Err(Error::InvalidData(
"Timestamp doesn't exist because of gap in local time".to_owned(),
));
}
}
return Ok(CalDateTime::Local(datetime));
@@ -145,7 +145,7 @@ impl CalDateTime {
return Ok(CalDateTime::Date(date));
}
Err(Error::Other(anyhow!("Invalid datetime format")))
Err(Error::InvalidData("Invalid datetime format".to_owned()))
}
pub fn utc(&self) -> DateTime<Utc> {