Add error_for_status_ref for functions
This commit is contained in:
parent
982fcb36ec
commit
cf8d664349
1 changed files with 2 additions and 0 deletions
|
@ -78,6 +78,7 @@ impl Client {
|
||||||
) -> Result<Vec<Post>> {
|
) -> Result<Vec<Post>> {
|
||||||
self.request_limiter().await;
|
self.request_limiter().await;
|
||||||
let res = self.list_posts_raw(limit, tags, page).await?;
|
let res = self.list_posts_raw(limit, tags, page).await?;
|
||||||
|
res.error_for_status_ref()?;
|
||||||
Ok(res.json::<RawPosts>().await?.into())
|
Ok(res.json::<RawPosts>().await?.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +102,7 @@ impl Client {
|
||||||
pub async fn get_post(&mut self, post_id: Id) -> Result<Post> {
|
pub async fn get_post(&mut self, post_id: Id) -> Result<Post> {
|
||||||
self.request_limiter().await;
|
self.request_limiter().await;
|
||||||
let res = self.get_post_raw(post_id).await?;
|
let res = self.get_post_raw(post_id).await?;
|
||||||
|
res.error_for_status_ref()?;
|
||||||
Ok(res.json::<RawPost>().await?.into())
|
Ok(res.json::<RawPost>().await?.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue