Skip to content

Commit 1c10502

Browse files
authored
better logging in case of jsonrpc errors (#199)
### TL;DR Improved error logging for nil block results in the RPC serializer. ### What changed? Enhanced the error handling in `SerializeFullBlocks` function by: 1. Including the original error from `rawBlock.Error` in the log message 2. Adding the original error details to the error message returned in the result ### How to test? 1. Trigger a scenario where a nil block result is returned from an RPC call 2. Verify that the logs now include the original error information 3. Confirm that the error message in the result contains the details from the original error ### Why make this change? This change provides more detailed error information when nil block results are encountered, making it easier to diagnose issues with RPC calls. The previous implementation only logged that a nil result was received without including the underlying error details, which limited troubleshooting capabilities.
2 parents e5f7511 + 8d2d4f0 commit 1c10502

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/rpc/serializer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ func SerializeFullBlocks(chainId *big.Int, blocks []RPCFetchBatchResult[common.R
2626
BlockNumber: rawBlock.BlockNumber,
2727
}
2828
if rawBlock.Result == nil {
29-
log.Warn().Msgf("Received a nil block result for block %s.", rawBlock.BlockNumber.String())
30-
result.Error = fmt.Errorf("received a nil block result from RPC")
29+
log.Warn().Err(rawBlock.Error).Msgf("Received a nil block result for block %s.", rawBlock.BlockNumber.String())
30+
result.Error = fmt.Errorf("received a nil block result from RPC. %v", rawBlock.Error)
3131
results = append(results, result)
3232
continue
3333
}

0 commit comments

Comments
 (0)