Add object ID to not found error
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
asonix 2023-12-11 13:21:05 -06:00
parent 63fe3a047f
commit 9971d3caeb
2 changed files with 15 additions and 14 deletions

View file

@ -49,6 +49,7 @@ impl From<crate::store::object_store::ObjectError> for StoreError {
e @ crate::store::object_store::ObjectError::Status(
actix_web::http::StatusCode::NOT_FOUND,
_,
_,
) => Self::ObjectNotFound(e),
e => Self::ObjectStore(e),
}

View file

@ -71,8 +71,8 @@ pub(crate) enum ObjectError {
#[error("Task cancelled")]
Cancelled,
#[error("Invalid status: {0}\n{1}")]
Status(StatusCode, String),
#[error("Invalid status {0} for {2:?} - {1}")]
Status(StatusCode, String, Option<String>),
}
impl From<JoinError> for ObjectError {
@ -144,7 +144,7 @@ where
Ok(buf)
}
async fn status_error(response: Response) -> StoreError {
async fn status_error(response: Response, obj: Option<String>) -> StoreError {
let status = response.status();
let body = match response.text().await {
@ -152,7 +152,7 @@ async fn status_error(response: Response) -> StoreError {
Ok(body) => body,
};
ObjectError::Status(status, body).into()
ObjectError::Status(status, body, obj).into()
}
#[async_trait::async_trait(?Send)]
@ -169,7 +169,7 @@ impl Store for ObjectStore {
.map_err(ObjectError::from)?;
if !response.status().is_success() {
return Err(status_error(response).await);
return Err(status_error(response, None).await);
}
Ok(())
@ -210,7 +210,7 @@ impl Store for ObjectStore {
.map_err(ObjectError::from)?;
if !response.status().is_success() {
return Err(status_error(response).await);
return Err(status_error(response, None).await);
}
return Ok(object_id);
@ -222,7 +222,7 @@ impl Store for ObjectStore {
let response = req.send().await.map_err(ObjectError::from)?;
if !response.status().is_success() {
return Err(status_error(response).await);
return Err(status_error(response, None).await);
}
let body = response.text().await.map_err(ObjectError::Request)?;
@ -266,7 +266,7 @@ impl Store for ObjectStore {
.map_err(ObjectError::from)?;
if !response.status().is_success() {
return Err(status_error(response).await);
return Err(status_error(response, None).await);
}
let etag = response
@ -307,7 +307,7 @@ impl Store for ObjectStore {
.map_err(ObjectError::from)?;
if !response.status().is_success() {
return Err(status_error(response).await);
return Err(status_error(response, None).await);
}
Ok(()) as Result<(), StoreError>
@ -336,7 +336,7 @@ impl Store for ObjectStore {
let response = req.body(bytes).send().await.map_err(ObjectError::from)?;
if !response.status().is_success() {
return Err(status_error(response).await);
return Err(status_error(response, None).await);
}
Ok(object_id)
@ -356,7 +356,7 @@ impl Store for ObjectStore {
.map_err(ObjectError::from)?;
if !response.status().is_success() {
return Err(status_error(response).await);
return Err(status_error(response, Some(identifier.as_str().to_string())).await);
}
Ok(Box::pin(
@ -382,7 +382,7 @@ impl Store for ObjectStore {
if !response.status().is_success() {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
status_error(response).await,
status_error(response, Some(identifier.as_str().to_string())).await,
));
}
@ -406,7 +406,7 @@ impl Store for ObjectStore {
.map_err(ObjectError::from)?;
if !response.status().is_success() {
return Err(status_error(response).await);
return Err(status_error(response, Some(identifier.as_str().to_string())).await);
}
let length = response
@ -430,7 +430,7 @@ impl Store for ObjectStore {
.map_err(ObjectError::from)?;
if !response.status().is_success() {
return Err(status_error(response).await);
return Err(status_error(response, Some(identifier.as_str().to_string())).await);
}
Ok(())