Skip to content

Commit

Permalink
rsc: Log failures to upload blob (#1623)
Browse files Browse the repository at this point in the history
  • Loading branch information
V-FEXrt authored Aug 5, 2024
1 parent 82f8e26 commit 2e0c2d0
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions rust/rsc/src/bin/rsc/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,18 @@ pub async fn create_blob(
})))
.await;

if let Err(msg) = result {
return (
StatusCode::INTERNAL_SERVER_ERROR,
Json(PostBlobResponse::Error {
message: msg.to_string(),
}),
);
}

let (blob_key, blob_size) = result.unwrap();
let (blob_key, blob_size) = match result {
Err(err) => {
tracing::error! {%err, "Failed to stream blob to store"};
return (
StatusCode::INTERNAL_SERVER_ERROR,
Json(PostBlobResponse::Error {
message: err.to_string(),
}),
);
}
Ok(resp) => resp,
};

let active_blob = blob::ActiveModel {
id: NotSet,
Expand All @@ -87,13 +89,14 @@ pub async fn create_blob(
};

match database::upsert_blob(db.as_ref(), active_blob).await {
Err(msg) => {
Err(err) => {
tracing::error! {%err, "Failed to upsert blob"};
return (
StatusCode::INTERNAL_SERVER_ERROR,
Json(PostBlobResponse::Error {
message: msg.to_string(),
message: err.to_string(),
}),
)
);
}
Ok(id) => parts.push(PostBlobResponsePart { id, name }),
}
Expand Down

0 comments on commit 2e0c2d0

Please sign in to comment.