1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use actix_web::error::PayloadError;
use actix_web::http::StatusCode;
use actix_web::{HttpResponse, ResponseError};
use quick_xml::DeError as XMLError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum XMLPayloadError {
#[error("Xml payload size is bigger than allowed")]
Overflow,
#[error("Content type error")]
ContentType,
#[error("Xml deserialize error: {0}")]
Deserialize(#[from] XMLError),
#[error("Error that occur during reading payload: {0}")]
Payload(#[from] PayloadError),
}
impl ResponseError for XMLPayloadError {
fn error_response(&self) -> actix_web::HttpResponse {
match *self {
XMLPayloadError::Overflow => HttpResponse::new(StatusCode::PAYLOAD_TOO_LARGE),
_ => HttpResponse::new(StatusCode::BAD_REQUEST),
}
}
}