dav: Add another error type

This commit is contained in:
Lennart
2024-06-16 13:02:28 +02:00
parent 98ea10d1a0
commit 9a783a6b65

View File

@@ -7,14 +7,22 @@ use thiserror::Error;
pub enum Error {
#[error("Not found")]
NotFound,
#[error("Bad request: {0}")]
BadRequest(String),
#[error("Unauthorized")]
Unauthorized,
#[error("Internal server error :(")]
InternalError,
#[error("prop {0} is read-only")]
PropReadOnly(String),
#[error(transparent)]
XmlDecodeError(#[from] quick_xml::DeError),
#[error("Internal server error")]
Other(#[from] anyhow::Error),
}
@@ -28,6 +36,7 @@ impl actix_web::error::ResponseError for Error {
Self::BadRequest(_) => StatusCode::BAD_REQUEST,
Self::Unauthorized => StatusCode::UNAUTHORIZED,
Self::XmlDecodeError(_) => StatusCode::BAD_REQUEST,
Error::PropReadOnly(_) => StatusCode::CONFLICT,
}
}