From e012ec8732e306467aaa8ef3a7ff3ca24e3819f0 Mon Sep 17 00:00:00 2001 From: james58899 Date: Fri, 29 Sep 2023 16:52:26 +0000 Subject: [PATCH] Log RPC server error --- src/rpc.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/rpc.rs b/src/rpc.rs index 4ba8158..8f6d875 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -481,13 +481,18 @@ The program will now terminate. } async fn send_request(&self, url: U) -> Result { - self.reqwest + let res = self.reqwest .get(url) .timeout(Duration::from_secs(600)) .send() - .and_then(|res| async { res.error_for_status() }) - .and_then(|res| res.text()) - .await + .await?; + + if let Err(err) = res.error_for_status_ref() { + warn!("Server response error: code={}, body={}", res.status(), res.text().await.unwrap_or_default()); + return Err(err); + } + + res.text().await } fn build_url(&self, action: &str, additional: &str, endpoint: Option<&str>) -> Url {