src/api2/admin/datastore/backup/service.rs: improve error logging

This commit is contained in:
Dietmar Maurer 2019-05-23 08:05:39 +02:00
parent 32e1bf4260
commit 907f5bb0d8

View File

@ -99,11 +99,13 @@ impl hyper::service::Service for BackupService {
Err(err) => { Err(err) => {
if let Some(apierr) = err.downcast_ref::<HttpError>() { if let Some(apierr) = err.downcast_ref::<HttpError>() {
let mut resp = Response::new(Body::from(apierr.message.clone())); let mut resp = Response::new(Body::from(apierr.message.clone()));
resp.extensions_mut().insert(ErrorMessageExtension(apierr.message.clone()));
*resp.status_mut() = apierr.code; *resp.status_mut() = apierr.code;
Self::log_response(worker, method, &path, &resp); Self::log_response(worker, method, &path, &resp);
Ok(resp) Ok(resp)
} else { } else {
let mut resp = Response::new(Body::from(err.to_string())); let mut resp = Response::new(Body::from(err.to_string()));
resp.extensions_mut().insert(ErrorMessageExtension(err.to_string()));
*resp.status_mut() = StatusCode::BAD_REQUEST; *resp.status_mut() = StatusCode::BAD_REQUEST;
Self::log_response(worker, method, &path, &resp); Self::log_response(worker, method, &path, &resp);
Ok(resp) Ok(resp)