diff options
author | Santo Cariotti <santo@dcariotti.me> | 2024-10-28 08:52:34 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2024-10-28 08:52:34 +0100 |
commit | 3803e989fb58a0abcca62026debd22618e49c955 (patch) | |
tree | 9487d3a70e4389d94123b64383fa7e260e44afe6 | |
parent | f642a91e3e2807abdc0df97fc70c2719d311eb31 (diff) |
Catch errors from audio server
-rw-r--r-- | src/audio.rs | 11 |
1 files changed, 9 insertions, 2 deletions
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() { |