main: add better error reporting for /bandcamp

This commit is contained in:
2026-06-08 10:27:59 +02:00
parent 50c55f0887
commit b53aa0fa06
+9 -7
View File
@@ -386,10 +386,13 @@ impl App {
let arg = parts.next().unwrap_or("");
match command {
"/bandcamp" => {
self.add_bandcamp_artifact(arg).await;
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::<u32>() {
@@ -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 {
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).unwrap();
let json = serde_json::to_string(&result)?;
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();
}
Ok(())
}
async fn speak(&mut self, text: String) {