From d00ce3448d2e40031a71964e4b3c8624c69c6720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Marcos?= <164224824+marcospb19-cw@users.noreply.github.com> Date: Thu, 18 Jul 2024 03:46:04 -0300 Subject: [PATCH] tweak: remove `error_from_source` (#1481) --- src/eth/rpc/rpc_server.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/eth/rpc/rpc_server.rs b/src/eth/rpc/rpc_server.rs index 8e09dd6b4..31a4b1c26 100644 --- a/src/eth/rpc/rpc_server.rs +++ b/src/eth/rpc/rpc_server.rs @@ -606,7 +606,7 @@ fn eth_estimate_gas(params: Params<'_>, ctx: Arc, ext: Extensions) - // internal error Err(e) => { tracing::error!(reason = ?e, "failed to execute eth_estimateGas because of unexpected error"); - Err(error_with_source(e, "failed to execute eth_estimateGas")) + Err(RpcError::Unexpected(e.context("failed to execute eth_estimateGas"))) } } } @@ -647,7 +647,7 @@ fn eth_call(params: Params<'_>, ctx: Arc, ext: Extensions) -> Result // internal error Err(e) => { tracing::error!(reason = ?e, "failed to execute eth_call because of unexpected error"); - Err(error_with_source(e, "failed to execute eth_call")) + Err(RpcError::Unexpected(e.context("failed to execute eth_call"))) } } } @@ -712,7 +712,7 @@ fn eth_send_raw_transaction(params: Params<'_>, ctx: Arc, ext: Exten } Err(e) => { tracing::error!(reason = ?e, "failed to execute eth_sendRawTransaction because of unexpected error"); - Err(error_with_source(e, "failed to execute eth_sendRawTransaction")) + Err(RpcError::Unexpected(e.context("failed to execute eth_sendRawTransaction"))) } } } @@ -968,13 +968,6 @@ fn hex_num_zero_padded(value: impl Into) -> String { format!("{:#0width$x}", value.into(), width = width) } -/// TODO: remove -#[inline(always)] -fn error_with_source(e: anyhow::Error, context: &str) -> RpcError { - let error_source = format!("{:?}", e.source()); - e.context(format!("{} {}", context, error_source)).into() -} - fn hex_zero() -> String { "0x0".to_owned() }