Skip to content

Commit

Permalink
WIP: extra logging for responses before parsing
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Mar 5, 2024
1 parent 5a27478 commit 33edb97
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions edu-ws/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ serde_with = "3"
thiserror = "1.0"
time = { version = "0.3", features = ["serde"] }
url = { version = "2.2", features = ["serde"] }
log = "0.4"

# SSO
base64 = "0.22"
Expand Down
24 changes: 17 additions & 7 deletions edu-ws/src/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ impl Client {
lang: Option<&'a str>,
}

self.http_client
let response = self
.http_client
.post(self.ws_url.clone())
.query(&WsQuery {
token: &self.token,
Expand All @@ -108,12 +109,21 @@ impl Client {
})
.send()
.await
.map_err(RequestError::HttpError)?
.json::<UntaggedResultHelper<T, Error>>()
.await
.map_err(RequestError::HttpError)?
.0
.map_err(RequestError::WsError)
.map_err(RequestError::HttpError)?;

log::trace!("response = {response:?}");

let text = response.text().await.map_err(RequestError::HttpError)?;

log::trace!("text = {text:?}");

let parsed = serde_json::from_str::<UntaggedResultHelper<T, Error>>(&text);

if let Err(err) = &parsed {
log::error!("error = {err:?}");
}

parsed.unwrap().0.map_err(RequestError::WsError)
}

pub async fn get_info(&self) -> Result<Info> {
Expand Down

0 comments on commit 33edb97

Please sign in to comment.