Skip to content

Commit

Permalink
feat(provider): add error log to alloy provider RPC calls
Browse files Browse the repository at this point in the history
  • Loading branch information
andysim3d authored and dancoombs committed Oct 15, 2024
1 parent 557f24a commit 707a916
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions crates/provider/src/alloy/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ where
method_logger.record_http(HttpCode::TwoHundreds);
method_logger.record_rpc(get_rpc_status_code(resp));
if resp.is_error() {
tracing::error!(
"alloy provider of method {} response with error: {}",
&method_name,
resp.as_error().unwrap()
);
let error = resp.as_error().unwrap();
if error.code < 0 {
tracing::error!(
"alloy provider of method {} response with error: {}",
&method_name,
error
);
}
}
}
Err(e) => {
Expand Down Expand Up @@ -152,6 +155,7 @@ fn get_rpc_status_from_code(code: i64) -> RpcCode {
-32602 => RpcCode::InvalidParams,
-32603 => RpcCode::InternalError,
x if (-32099..=-32000).contains(&x) => RpcCode::ServerError,
x if x >= 0 => RpcCode::Success,
_ => RpcCode::Other,
}
}
Expand Down

0 comments on commit 707a916

Please sign in to comment.