Skip to content

Commit

Permalink
Log RPC server error
Browse files Browse the repository at this point in the history
  • Loading branch information
james58899 committed Sep 29, 2023
1 parent 5e48371 commit e012ec8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,18 @@ The program will now terminate.
}

async fn send_request<U: IntoUrl>(&self, url: U) -> Result<String, reqwest::Error> {
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 {
Expand Down

0 comments on commit e012ec8

Please sign in to comment.