mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-22 19:49:26 +00:00
work on errors
This commit is contained in:
@@ -2,6 +2,7 @@ use actix_web::{web::Data, HttpRequest};
|
||||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use rustical_auth::AuthInfo;
|
||||
use rustical_dav::error::Error;
|
||||
use rustical_dav::{
|
||||
resource::Resource,
|
||||
xml_snippets::{HrefElement, TextNode},
|
||||
@@ -174,7 +175,7 @@ impl<C: CalendarStore + ?Sized> Resource for CalendarResource<C> {
|
||||
_auth_info: AuthInfo,
|
||||
uri_components: Self::UriComponents,
|
||||
prefix: String,
|
||||
) -> Result<Self> {
|
||||
) -> Result<Self, Error> {
|
||||
let cal_store = req
|
||||
.app_data::<Data<RwLock<C>>>()
|
||||
.ok_or(anyhow!("no calendar store in app_data!"))?
|
||||
@@ -182,7 +183,13 @@ impl<C: CalendarStore + ?Sized> Resource for CalendarResource<C> {
|
||||
.into_inner();
|
||||
|
||||
let (principal, cid) = uri_components;
|
||||
let calendar = cal_store.read().await.get_calendar(&cid).await?;
|
||||
// TODO: fix errors
|
||||
let calendar = cal_store
|
||||
.read()
|
||||
.await
|
||||
.get_calendar(&cid)
|
||||
.await
|
||||
.map_err(|_e| Error::NotFound)?;
|
||||
Ok(Self {
|
||||
cal_store,
|
||||
calendar,
|
||||
|
||||
@@ -2,6 +2,7 @@ use actix_web::{web::Data, HttpRequest};
|
||||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use rustical_auth::AuthInfo;
|
||||
use rustical_dav::error::Error;
|
||||
use rustical_dav::{resource::Resource, xml_snippets::TextNode};
|
||||
use rustical_store::calendar::CalendarStore;
|
||||
use rustical_store::event::Event;
|
||||
@@ -53,7 +54,7 @@ impl<C: CalendarStore + ?Sized> Resource for EventResource<C> {
|
||||
_auth_info: AuthInfo,
|
||||
uri_components: Self::UriComponents,
|
||||
_prefix: String,
|
||||
) -> Result<Self> {
|
||||
) -> Result<Self, Error> {
|
||||
let (_principal, cid, uid) = uri_components;
|
||||
|
||||
let cal_store = req
|
||||
|
||||
@@ -2,6 +2,7 @@ use actix_web::{web::Data, HttpRequest};
|
||||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use rustical_auth::AuthInfo;
|
||||
use rustical_dav::error::Error;
|
||||
use rustical_dav::{resource::Resource, xml_snippets::HrefElement};
|
||||
use rustical_store::calendar::CalendarStore;
|
||||
use serde::Serialize;
|
||||
@@ -88,7 +89,7 @@ impl<C: CalendarStore + ?Sized> Resource for PrincipalCalendarsResource<C> {
|
||||
auth_info: AuthInfo,
|
||||
_uri_components: Self::UriComponents,
|
||||
prefix: String,
|
||||
) -> Result<Self> {
|
||||
) -> Result<Self, Error> {
|
||||
let cal_store = req
|
||||
.app_data::<Data<RwLock<C>>>()
|
||||
.ok_or(anyhow!("no calendar store in app_data!"))?
|
||||
|
||||
@@ -2,6 +2,7 @@ use actix_web::HttpRequest;
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use rustical_auth::AuthInfo;
|
||||
use rustical_dav::error::Error;
|
||||
use rustical_dav::{resource::Resource, xml_snippets::HrefElement};
|
||||
use serde::Serialize;
|
||||
use strum::{EnumProperty, EnumString, IntoStaticStr, VariantNames};
|
||||
@@ -52,7 +53,7 @@ impl Resource for RootResource {
|
||||
auth_info: AuthInfo,
|
||||
_uri_components: Self::UriComponents,
|
||||
prefix: String,
|
||||
) -> Result<Self> {
|
||||
) -> Result<Self, Error> {
|
||||
Ok(Self {
|
||||
prefix,
|
||||
principal: auth_info.user_id,
|
||||
|
||||
Reference in New Issue
Block a user