From 978c00c1dc85295d2e12daac34b7f7e78cd633a9 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Fri, 19 Jan 2024 13:04:11 +0100 Subject: [PATCH] feat(paheko): print error details --- src/paheko.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/paheko.rs b/src/paheko.rs index d48c753..230614a 100644 --- a/src/paheko.rs +++ b/src/paheko.rs @@ -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()) + } }