mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 11:42:25 +00:00
Move ical-related stuff to rustical_ical crate
This commit is contained in:
@@ -23,6 +23,9 @@ pub enum Error {
|
||||
|
||||
#[error(transparent)]
|
||||
XmlDecodeError(#[from] rustical_xml::XmlError),
|
||||
|
||||
#[error(transparent)]
|
||||
IcalError(#[from] rustical_ical::Error),
|
||||
}
|
||||
|
||||
impl actix_web::ResponseError for Error {
|
||||
@@ -30,9 +33,7 @@ impl actix_web::ResponseError for Error {
|
||||
match self {
|
||||
Error::StoreError(err) => match err {
|
||||
rustical_store::Error::NotFound => StatusCode::NOT_FOUND,
|
||||
rustical_store::Error::InvalidData(_) => StatusCode::BAD_REQUEST,
|
||||
rustical_store::Error::AlreadyExists => StatusCode::CONFLICT,
|
||||
rustical_store::Error::ParserError(_) => StatusCode::BAD_REQUEST,
|
||||
rustical_store::Error::ReadOnly => StatusCode::FORBIDDEN,
|
||||
_ => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
},
|
||||
@@ -42,12 +43,14 @@ impl actix_web::ResponseError for Error {
|
||||
Error::XmlDecodeError(_) => StatusCode::BAD_REQUEST,
|
||||
Error::NotImplemented => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Error::NotFound => StatusCode::NOT_FOUND,
|
||||
Self::IcalError(err) => err.status_code(),
|
||||
}
|
||||
}
|
||||
fn error_response(&self) -> actix_web::HttpResponse<actix_web::body::BoxBody> {
|
||||
error!("Error: {self}");
|
||||
match self {
|
||||
Error::DavError(err) => err.error_response(),
|
||||
Error::IcalError(err) => err.error_response(),
|
||||
_ => HttpResponse::build(self.status_code()).body(self.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user