From 3803e989fb58a0abcca62026debd22618e49c955 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 28 Oct 2024 08:52:34 +0100 Subject: Catch errors from audio server --- src/audio.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/audio.rs') diff --git a/src/audio.rs b/src/audio.rs index 64ee223..a67f3da 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -28,13 +28,20 @@ pub async fn tts(text: String, filename: String) -> Result<(), String> { // Send POST request let client = reqwest::Client::new(); - let response = client + let response; + + match client .post(url) .header(AUTHORIZATION, api_key) .json(&body) .send() .await - .unwrap(); + { + Ok(r) => response = r, + Err(e) => { + return Err(format!("Error creating new audio: {}", e)); + } + }; // Check for successful response if response.status().is_success() { -- cgit v1.2.3-18-g5258