diff --git a/Cargo.lock b/Cargo.lock index 4f345e1..dd3a7e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -370,6 +370,7 @@ dependencies = [ "edu-ws-derive", "hex", "html-escape", + "log", "md5", "rand", "reqwest", diff --git a/edu-ws/Cargo.toml b/edu-ws/Cargo.toml index 5b57299..8caa18e 100644 --- a/edu-ws/Cargo.toml +++ b/edu-ws/Cargo.toml @@ -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" diff --git a/edu-ws/src/ws.rs b/edu-ws/src/ws.rs index 7d376cc..e1f91ad 100644 --- a/edu-ws/src/ws.rs +++ b/edu-ws/src/ws.rs @@ -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, @@ -108,12 +109,21 @@ impl Client { }) .send() .await - .map_err(RequestError::HttpError)? - .json::>() - .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::>(&text); + + if let Err(err) = &parsed { + log::error!("error = {err:?}"); + } + + parsed.unwrap().0.map_err(RequestError::WsError) } pub async fn get_info(&self) -> Result {