From 72ea822f578b8799f18c0540bcd31f3af447d609 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Wed, 29 Oct 2025 15:06:03 -0400 Subject: [PATCH] tsk-179: Improved error handling --- src/callers/queue/song.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/callers/queue/song.rs b/src/callers/queue/song.rs index 7d39246..bbdac0f 100644 --- a/src/callers/queue/song.rs +++ b/src/callers/queue/song.rs @@ -157,15 +157,22 @@ pub mod endpoint { match super::is_song_valid(&raw_data).await { Ok(valid) => { if valid { - let queue_repo = repo::song::insert( + match repo::song::insert( &pool, &raw_data, &file_name, &crate::repo::queue::song::status::PENDING.to_string(), ) - .await - .unwrap(); - results.push(queue_repo); + .await { + Ok(queued_song) => { + results.push(queued_song); + } + Err(err) => { + response.message = err.to_string(); + return (axum::http::StatusCode::INTERNAL_SERVER_ERROR, + axum::Json(response)); + } + } } else { response.message = String::from("Invalid song type"); return (axum::http::StatusCode::BAD_REQUEST, axum::Json(response));