diff --git a/src/gitea.rs b/src/gitea.rs index 4da05b4..1a3581e 100644 --- a/src/gitea.rs +++ b/src/gitea.rs @@ -47,6 +47,10 @@ impl GiteaAPI { .send() .await?; + if !res.status().is_success() { + return Err(anyhow::anyhow!("Failed to comment: {}", res.status())); + } + res.json::().await.map_err(anyhow::Error::from) } @@ -61,15 +65,20 @@ impl GiteaAPI { self.base_url, full_name, comment_id ); - self.client + let res = self + .client .patch(url) .json(&json!({ "body": body })) .send() - .await - .map(|_| ()) - .map_err(anyhow::Error::from) + .await?; + + if !res.status().is_success() { + return Err(anyhow::anyhow!("Failed to comment: {}", res.status())); + } + + Ok(()) } }