Add endpoint to copy shift plan week

This commit is contained in:
Simon Goller 2024-06-14 09:53:57 +02:00
parent e7af89f1cd
commit f894bf325d
4 changed files with 102 additions and 2 deletions

View file

@ -107,6 +107,12 @@ pub enum RestError {
#[error("Inconsistent id. Got {0} in path but {1} in body")]
InconsistentId(Uuid, Uuid),
#[error("Bad request: {0}")]
BadRequest(String),
#[error("Parse int error: {0}")]
ParseIntError(#[from] std::num::ParseIntError),
}
fn error_handler(result: Result<Response, RestError>) -> Response {
@ -119,6 +125,14 @@ fn error_handler(result: Result<Response, RestError>) -> Response {
.status(400)
.body(Body::new(err.to_string()))
.unwrap(),
Err(err @ RestError::BadRequest(_)) => Response::builder()
.status(400)
.body(Body::new(err.to_string()))
.unwrap(),
Err(err @ RestError::ParseIntError(_)) => Response::builder()
.status(400)
.body(Body::new(err.to_string()))
.unwrap(),
Err(RestError::ServiceError(service::ServiceError::Forbidden)) => {
Response::builder().status(403).body(Body::empty()).unwrap()
}