Add http status check for gitea api
This commit is contained in:
+13
-4
@@ -47,6 +47,10 @@ impl GiteaAPI {
|
|||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
if !res.status().is_success() {
|
||||||
|
return Err(anyhow::anyhow!("Failed to comment: {}", res.status()));
|
||||||
|
}
|
||||||
|
|
||||||
res.json::<Comment>().await.map_err(anyhow::Error::from)
|
res.json::<Comment>().await.map_err(anyhow::Error::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,15 +65,20 @@ impl GiteaAPI {
|
|||||||
self.base_url, full_name, comment_id
|
self.base_url, full_name, comment_id
|
||||||
);
|
);
|
||||||
|
|
||||||
self.client
|
let res = self
|
||||||
|
.client
|
||||||
.patch(url)
|
.patch(url)
|
||||||
.json(&json!({
|
.json(&json!({
|
||||||
"body": body
|
"body": body
|
||||||
}))
|
}))
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await?;
|
||||||
.map(|_| ())
|
|
||||||
.map_err(anyhow::Error::from)
|
if !res.status().is_success() {
|
||||||
|
return Err(anyhow::anyhow!("Failed to comment: {}", res.status()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user