Skip to content

Commit 51b75c8

Browse files
authored
feat(anvil): emit warning server side on failing request (foundry-rs#9890)
* log error if request response fails * use warning as it is not a server side failure but a failing client request * prefer using node_info! macro * improve error format
1 parent 29cba10 commit 51b75c8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crates/anvil/src/eth/api.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl EthApi {
161161
/// Executes the [EthRequest] and returns an RPC [ResponseResult].
162162
pub async fn execute(&self, request: EthRequest) -> ResponseResult {
163163
trace!(target: "rpc::api", "executing eth request");
164-
match request {
164+
let response = match request.clone() {
165165
EthRequest::Web3ClientVersion(()) => self.client_version().to_rpc_result(),
166166
EthRequest::Web3Sha3(content) => self.sha3(content).to_rpc_result(),
167167
EthRequest::EthGetAccount(addr, block) => {
@@ -465,7 +465,15 @@ impl EthApi {
465465
EthRequest::AnvilSetExecutor(executor_pk) => {
466466
self.anvil_set_executor(executor_pk).to_rpc_result()
467467
}
468+
};
469+
470+
if let ResponseResult::Error(err) = &response {
471+
node_info!("\nRPC request failed:");
472+
node_info!(" Request: {:?}", request);
473+
node_info!(" Error: {}\n", err);
468474
}
475+
476+
response
469477
}
470478

471479
fn sign_request(

0 commit comments

Comments
 (0)