Skip to content

Commit

Permalink
Remove some anyhow dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
lennart-k committed Jan 23, 2025
1 parent e616ab0 commit 1442d79
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 20 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ hex = { version = "0.4.3", features = ["serde"] }
mime_guess = "2.0.5"
itertools = "0.14"
log = "0.4"
strum = { version = "0.26", features = ["strum_macros", "derive"] }
derive_more = { version = "1.0", features = [
"from",
"try_into",
Expand Down
1 change: 0 additions & 1 deletion crates/caldav/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ repository.workspace = true
publish = false

[dependencies]
anyhow = { workspace = true }
actix-web = { workspace = true }
async-trait = { workspace = true }
thiserror = { workspace = true }
Expand Down
3 changes: 1 addition & 2 deletions crates/caldav/src/calendar/methods/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ pub async fn route_post<C: CalendarStore, S: SubscriptionStore>(
let sub_id = uuid::Uuid::new_v4().to_string();

let expires = if let Some(expires) = request.expires {
chrono::DateTime::parse_from_rfc2822(&expires)
.map_err(|err| crate::Error::Other(err.into()))?
chrono::DateTime::parse_from_rfc2822(&expires).map_err(Error::from)?
} else {
chrono::Utc::now().fixed_offset() + chrono::Duration::weeks(1)
};
Expand Down
8 changes: 4 additions & 4 deletions crates/caldav/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ pub enum Error {
StoreError(#[from] rustical_store::Error),

#[error(transparent)]
DavError(#[from] rustical_dav::Error),
ChronoParseError(#[from] chrono::ParseError),

#[error(transparent)]
XmlDecodeError(#[from] rustical_xml::XmlError),
DavError(#[from] rustical_dav::Error),

#[error(transparent)]
Other(#[from] anyhow::Error),
XmlDecodeError(#[from] rustical_xml::XmlError),
}

impl actix_web::ResponseError for Error {
Expand All @@ -33,11 +33,11 @@ impl actix_web::ResponseError for Error {
rustical_store::Error::InvalidData(_) => StatusCode::BAD_REQUEST,
_ => StatusCode::INTERNAL_SERVER_ERROR,
},
Error::ChronoParseError(_) => StatusCode::INTERNAL_SERVER_ERROR,
Error::DavError(err) => err.status_code(),
Error::Unauthorized => StatusCode::UNAUTHORIZED,
Error::XmlDecodeError(_) => StatusCode::BAD_REQUEST,
Error::NotImplemented => StatusCode::INTERNAL_SERVER_ERROR,
Error::Other(_) => StatusCode::INTERNAL_SERVER_ERROR,
Error::NotFound => StatusCode::NOT_FOUND,
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/carddav/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ repository.workspace = true
publish = false

[dependencies]
anyhow = { workspace = true }
actix-web = { workspace = true }
async-trait = { workspace = true }
thiserror = { workspace = true }
Expand Down
3 changes: 1 addition & 2 deletions crates/carddav/src/addressbook/methods/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ pub async fn route_post<A: AddressbookStore, S: SubscriptionStore>(
let sub_id = uuid::Uuid::new_v4().to_string();

let expires = if let Some(expires) = request.expires {
chrono::DateTime::parse_from_rfc2822(&expires)
.map_err(|err| crate::Error::Other(err.into()))?
chrono::DateTime::parse_from_rfc2822(&expires).map_err(Error::from)?
} else {
chrono::Utc::now().fixed_offset() + chrono::Duration::weeks(1)
};
Expand Down
8 changes: 4 additions & 4 deletions crates/carddav/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ pub enum Error {
StoreError(#[from] rustical_store::Error),

#[error(transparent)]
DavError(#[from] rustical_dav::Error),
ChronoParseError(#[from] chrono::ParseError),

#[error(transparent)]
XmlDecodeError(#[from] rustical_xml::XmlError),
DavError(#[from] rustical_dav::Error),

#[error(transparent)]
Other(#[from] anyhow::Error),
XmlDecodeError(#[from] rustical_xml::XmlError),
}

impl actix_web::ResponseError for Error {
Expand All @@ -33,11 +33,11 @@ impl actix_web::ResponseError for Error {
rustical_store::Error::InvalidData(_) => StatusCode::BAD_REQUEST,
_ => StatusCode::INTERNAL_SERVER_ERROR,
},
Error::ChronoParseError(_) => StatusCode::INTERNAL_SERVER_ERROR,
Error::DavError(err) => err.status_code(),
Error::Unauthorized => StatusCode::UNAUTHORIZED,
Error::XmlDecodeError(_) => StatusCode::BAD_REQUEST,
Error::NotImplemented => StatusCode::INTERNAL_SERVER_ERROR,
Error::Other(_) => StatusCode::INTERNAL_SERVER_ERROR,
Error::NotFound => StatusCode::NOT_FOUND,
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ askama.workspace = true
askama_actix = { workspace = true }
actix-session = { workspace = true }
serde = { workspace = true }
anyhow = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
actix-web = { workspace = true }
Expand Down
1 change: 0 additions & 1 deletion crates/store/src/calendar/object.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use super::{CalDateTime, EventObject, JournalObject, TodoObject};
use crate::Error;
use anyhow::Result;
use ical::parser::{ical::component::IcalTimeZone, Component};
use serde::Serialize;
use sha2::{Digest, Sha256};
Expand Down

0 comments on commit 1442d79

Please sign in to comment.