summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2024-10-28 08:52:34 +0100
committerSanto Cariotti <santo@dcariotti.me>2024-10-28 08:52:34 +0100
commit3803e989fb58a0abcca62026debd22618e49c955 (patch)
tree9487d3a70e4389d94123b64383fa7e260e44afe6
parentf642a91e3e2807abdc0df97fc70c2719d311eb31 (diff)
Catch errors from audio server
-rw-r--r--src/audio.rs11
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() {