Added messageresource parsing from error requests

This commit is contained in:
Franklin 2022-09-06 11:52:27 -04:00
parent b97d0e8bec
commit efacc602af
1 changed files with 4 additions and 1 deletions

View File

@ -38,7 +38,10 @@ pub async fn perform_request<B: Serialize, R: DeserializeOwned>(
Err(Error::UnexpectedStatusCode(
expected_status_code,
res.status().as_u16(),
MessageResource::new_from_str(&res.text().await.unwrap()),
match res.json::<MessageResource>().await {
Ok(message) => message,
Err(e) => MessageResource::new_from_err(e.to_string()),
},
))
}
}