From b3584639287457a36dd27fe9258ab39295ad3a9b Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Thu, 26 Jan 2023 19:18:58 -0800 Subject: [PATCH] use error_builder --- .../src/bin/web3_proxy_cli/sentryd/compare.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/web3_proxy/src/bin/web3_proxy_cli/sentryd/compare.rs b/web3_proxy/src/bin/web3_proxy_cli/sentryd/compare.rs index 8417061c..e5225fbc 100644 --- a/web3_proxy/src/bin/web3_proxy_cli/sentryd/compare.rs +++ b/web3_proxy/src/bin/web3_proxy_cli/sentryd/compare.rs @@ -61,24 +61,22 @@ pub async fn main( .map_err(|x| error_builder.build(x))?; if !a.status().is_success() { - return Err(anyhow::anyhow!( - "bad response from {}: {}", - rpc, - response.status(), - )); + return error_builder.result(anyhow!("bad response from {}: {}", rpc, a.status())); } // TODO: capture response headers now in case of error. store them in the extra data on the pager duty alert let headers = format!("{:#?}", a.headers()); - let a = a + let body = a .text() .await - .context(format!("failed parsing body from {}", rpc))?; + .context(format!("failed parsing body from {}", rpc)) + .map_err(|x| error_builder.build(x))?; let a: JsonRpcResponse> = serde_json::from_str(&body) .context(format!("body: {}", body)) - .context(format!("failed parsing json from {}", rpc))?; + .context(format!("failed parsing json from {}", rpc)) + .map_err(|x| error_builder.build(x))?; let a = if let Some(block) = a.result { block