tsk-179: Improved error handling

This commit is contained in:
kdeng00
2025-10-29 15:06:03 -04:00
parent 087e214eed
commit 72ea822f57
+11 -4
View File
@@ -157,15 +157,22 @@ pub mod endpoint {
match super::is_song_valid(&raw_data).await { match super::is_song_valid(&raw_data).await {
Ok(valid) => { Ok(valid) => {
if valid { if valid {
let queue_repo = repo::song::insert( match repo::song::insert(
&pool, &pool,
&raw_data, &raw_data,
&file_name, &file_name,
&crate::repo::queue::song::status::PENDING.to_string(), &crate::repo::queue::song::status::PENDING.to_string(),
) )
.await .await {
.unwrap(); Ok(queued_song) => {
results.push(queue_repo); results.push(queued_song);
}
Err(err) => {
response.message = err.to_string();
return (axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response));
}
}
} else { } else {
response.message = String::from("Invalid song type"); response.message = String::from("Invalid song type");
return (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)); return (axum::http::StatusCode::BAD_REQUEST, axum::Json(response));