feat(paheko): print error details

This commit is contained in:
Matthieu Bessat 2024-01-19 13:04:11 +01:00
parent bbea78cea3
commit 978c00c1dc
1 changed files with 9 additions and 0 deletions

View File

@ -285,6 +285,7 @@ impl AuthentifiedClient {
.json(&payload)
.send().await?;
if res.status() != 200 {
self.show_paheko_err(res).await;
return Err(APIClientError::InvalidStatusCode.into());
}
res.json().await.context("Sql query")
@ -337,6 +338,7 @@ impl AuthentifiedClient {
.get(path)
.send().await?;
if res.status() != 200 {
self.show_paheko_err(res).await;
return Err(APIClientError::InvalidStatusCode.into());
}
res.json().await.context("Get accounting years")
@ -428,6 +430,7 @@ impl AuthentifiedClient {
.send().await?;
if res.status() != 200 {
self.show_paheko_err(res).await;
return Err(APIClientError::InvalidStatusCode.into());
}
Ok(
@ -476,6 +479,7 @@ impl AuthentifiedClient {
.send().await?;
if res.status() != 200 {
self.show_paheko_err(res).await;
return Err(APIClientError::InvalidStatusCode.into());
}
Ok(UserServiceRegistration {
@ -514,8 +518,13 @@ impl AuthentifiedClient {
.send().await?;
if res.status() != 200 {
self.show_paheko_err(res).await;
return Err(APIClientError::InvalidStatusCode.into());
}
Ok(())
}
async fn show_paheko_err(&self, err_response: reqwest::Response) -> () {
eprintln!("Paheko Error Details: {:?} {:?}", err_response.status(), err_response.text().await.unwrap())
}
}