From a9bf42dcc5b1ea2d254d903f289a8772da7bd821 Mon Sep 17 00:00:00 2001 From: Lennart <18233294+lennart-k@users.noreply.github.com> Date: Thu, 14 Sep 2023 13:52:57 +0200 Subject: [PATCH] Refactor error handling --- crates/caldav/src/routes/calendar.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/crates/caldav/src/routes/calendar.rs b/crates/caldav/src/routes/calendar.rs index 286a7e5..5602abd 100644 --- a/crates/caldav/src/routes/calendar.rs +++ b/crates/caldav/src/routes/calendar.rs @@ -1,5 +1,6 @@ use crate::resources::event::EventResource; -use crate::{CalDavContext, Error}; +use crate::CalDavContext; +use crate::Error; use actix_web::http::header::ContentType; use actix_web::web::{Data, Path}; use actix_web::{HttpRequest, HttpResponse}; @@ -57,17 +58,14 @@ async fn handle_report_calendar_query( event, }; // TODO: proper error handling - let propfind_result = event_resource - .propfind(props.clone()) - .map_err(|_e| quick_xml::Error::TextNotFound)?; + let propfind_result = event_resource.propfind(props.clone())?; writer.write_event(quick_xml::events::Event::Text(BytesText::from_escaped( propfind_result, )))?; } Ok(()) - }) - .map_err(|_e| Error::InternalError)?; + })?; Ok(HttpResponse::MultiStatus() .content_type(ContentType::xml()) @@ -169,8 +167,7 @@ pub async fn route_mkcol_calendar( cid.clone(), auth.inner.user_id.clone(), ) - .await - .map_err(|_e| Error::InternalError)?; + .await?; Ok(HttpResponse::Created().body("")) }