Print uniswap api response text and status in case of error
@@ -38,7 +38,7 @@ impl UniswapTokenWatcher {
let query = format!("{{token(id: \"{:#x}\"){{untrackedVolumeUSD}}}}", address);
- let response = self
+ let raw_response = self
.client
.post(&self.addr)
.json(&serde_json::json!({
@@ -47,9 +47,19 @@ impl UniswapTokenWatcher {
.timeout(REQUEST_TIMEOUT)
.send()
.await
- .map_err(|err| anyhow::format_err!("Uniswap API request failed: {}", err))?
- .json::<GraphqlResponse>()
- .await?;
+ .map_err(|err| anyhow::format_err!("Uniswap API request failed: {}", err))?;
+
+ let response_status = raw_response.status();
+ let response_text = raw_response.text().await?;
+
+ let response: GraphqlResponse = serde_json::from_str(&response_text).map_err(|err| {
+ anyhow::format_err!(
+ "Error: {} while decoding response: {} with status: {}",
+ err,
+ response_text,
+ response_status
+ )
+ })?;
metrics::histogram!("ticker.uniswap_watcher.get_market_volume", start.elapsed());
