mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 07:02:24 +00:00
Refactor error handling
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
use crate::resources::event::EventResource;
|
use crate::resources::event::EventResource;
|
||||||
use crate::{CalDavContext, Error};
|
use crate::CalDavContext;
|
||||||
|
use crate::Error;
|
||||||
use actix_web::http::header::ContentType;
|
use actix_web::http::header::ContentType;
|
||||||
use actix_web::web::{Data, Path};
|
use actix_web::web::{Data, Path};
|
||||||
use actix_web::{HttpRequest, HttpResponse};
|
use actix_web::{HttpRequest, HttpResponse};
|
||||||
@@ -57,17 +58,14 @@ async fn handle_report_calendar_query<C: CalendarStore>(
|
|||||||
event,
|
event,
|
||||||
};
|
};
|
||||||
// TODO: proper error handling
|
// TODO: proper error handling
|
||||||
let propfind_result = event_resource
|
let propfind_result = event_resource.propfind(props.clone())?;
|
||||||
.propfind(props.clone())
|
|
||||||
.map_err(|_e| quick_xml::Error::TextNotFound)?;
|
|
||||||
|
|
||||||
writer.write_event(quick_xml::events::Event::Text(BytesText::from_escaped(
|
writer.write_event(quick_xml::events::Event::Text(BytesText::from_escaped(
|
||||||
propfind_result,
|
propfind_result,
|
||||||
)))?;
|
)))?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})?;
|
||||||
.map_err(|_e| Error::InternalError)?;
|
|
||||||
|
|
||||||
Ok(HttpResponse::MultiStatus()
|
Ok(HttpResponse::MultiStatus()
|
||||||
.content_type(ContentType::xml())
|
.content_type(ContentType::xml())
|
||||||
@@ -169,8 +167,7 @@ pub async fn route_mkcol_calendar<A: CheckAuthentication, C: CalendarStore>(
|
|||||||
cid.clone(),
|
cid.clone(),
|
||||||
auth.inner.user_id.clone(),
|
auth.inner.user_id.clone(),
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
.map_err(|_e| Error::InternalError)?;
|
|
||||||
|
|
||||||
Ok(HttpResponse::Created().body(""))
|
Ok(HttpResponse::Created().body(""))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user