mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 16:32:29 +00:00
xml: Some work on errors
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use actix_web::{http::StatusCode, HttpResponse};
|
||||
use rustical_xml::XmlError;
|
||||
use thiserror::Error;
|
||||
use tracing::error;
|
||||
|
||||
@@ -33,7 +34,15 @@ impl actix_web::error::ResponseError for Error {
|
||||
Self::NotFound => StatusCode::NOT_FOUND,
|
||||
Self::BadRequest(_) => StatusCode::BAD_REQUEST,
|
||||
Self::Unauthorized => StatusCode::UNAUTHORIZED,
|
||||
Self::XmlError(_) => StatusCode::BAD_REQUEST,
|
||||
Self::XmlError(error) => match &error {
|
||||
XmlError::InvalidTag(..)
|
||||
| XmlError::MissingField(_)
|
||||
| XmlError::UnsupportedEvent(_)
|
||||
| XmlError::InvalidVariant(_)
|
||||
| XmlError::InvalidFieldName(_, _)
|
||||
| XmlError::InvalidValue(_) => StatusCode::UNPROCESSABLE_ENTITY,
|
||||
_ => StatusCode::BAD_REQUEST,
|
||||
},
|
||||
Error::PropReadOnly => StatusCode::CONFLICT,
|
||||
Self::IOError(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ impl ValueDeserialize for SyncLevel {
|
||||
"1" => Self::One,
|
||||
"Infinity" => Self::Infinity,
|
||||
_ => {
|
||||
return Err(rustical_xml::XmlError::Other(
|
||||
"Invalid sync-level".to_owned(),
|
||||
return Err(rustical_xml::XmlError::InvalidValue(
|
||||
rustical_xml::ParseValueError::Other("Invalid sync-level".to_owned()),
|
||||
))
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user