From 9ee6ff06ba4d129d615a11dc153488471431c33f Mon Sep 17 00:00:00 2001 From: Ashley Coleman Date: Mon, 5 Aug 2024 09:25:09 -0700 Subject: [PATCH] rsc: Log failures to upload blob --- rust/rsc/src/bin/rsc/blob.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/rust/rsc/src/bin/rsc/blob.rs b/rust/rsc/src/bin/rsc/blob.rs index 65f6ca737..fb57f8201 100644 --- a/rust/rsc/src/bin/rsc/blob.rs +++ b/rust/rsc/src/bin/rsc/blob.rs @@ -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, @@ -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 }), }