From b53aa0fa06b6eaf4b63e187c91a459f00a97c866 Mon Sep 17 00:00:00 2001 From: Victoria Fischer Date: Mon, 8 Jun 2026 10:27:59 +0200 Subject: [PATCH] main: add better error reporting for /bandcamp --- src/main.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8d441b7..5580921 100644 --- a/src/main.rs +++ b/src/main.rs @@ -386,10 +386,13 @@ impl App { let arg = parts.next().unwrap_or(""); match command { "/bandcamp" => { - self.add_bandcamp_artifact(arg).await; - self.sys_message_sink.send(format!("Added Bandcamp artifact from {}", arg)).await.unwrap(); - self.next_actions.push(ConversationEntry::ShipComputer(format!("Incoming transmission from {}", arg))); - self.regenerate_responses(); + if let Err(err) = self.add_bandcamp_artifact(arg).await { + self.sys_message_sink.send(format!("Failed to fetch artifact: {:?}", err)).await.unwrap(); + } else { + self.sys_message_sink.send(format!("Added Bandcamp artifact from {}", arg)).await.unwrap(); + self.next_actions.push(ConversationEntry::ShipComputer(format!("Incoming transmission from {}", arg))); + self.regenerate_responses(); + } }, "/episode" => { if let Ok(episode_number) = arg.trim().parse::() { @@ -507,15 +510,14 @@ impl App { } } - async fn add_bandcamp_artifact(&mut self, url: &str) { - if let Ok(album) = bandcamp::album_from_url(url).await { - let result: BandcampResult = album.into(); - let json = serde_json::to_string(&result).unwrap(); - self.direction.artifacts.push(json); - self.sys_message_sink.send("Added bandcamp album".into()).await.unwrap(); - } else { - self.sys_message_sink.send("Could not fetch bandcamp data! Is that a proper URL?".into()).await.unwrap(); - } + async fn add_bandcamp_artifact(&mut self, url: &str) -> Result<(), BandcampError> { + let album = bandcamp::album_from_url(url).await?; + let result: BandcampResult = album.into(); + let json = serde_json::to_string(&result)?; + self.direction.artifacts.push(json); + self.sys_message_sink.send("Added bandcamp album".into()).await.unwrap(); + + Ok(()) } async fn speak(&mut self, text: String) {