From 1e973a96b4b52d2a3af07a935ad41a4358924422 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Thu, 31 Mar 2022 21:16:03 +0200 Subject: [PATCH] eth: clarify the error string on getlogs failure (#24617) This PR makes the errors we spit out a bit more clear about what block is problematic. --- eth/api_backend.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eth/api_backend.go b/eth/api_backend.go index 6577ac1e1a..8eb6c02af7 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -19,6 +19,7 @@ package eth import ( "context" "errors" + "fmt" "math/big" "time" @@ -185,11 +186,11 @@ func (b *EthAPIBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*typ db := b.eth.ChainDb() number := rawdb.ReadHeaderNumber(db, hash) if number == nil { - return nil, errors.New("failed to get block number from hash") + return nil, fmt.Errorf("failed to get block number for hash %#x", hash) } logs := rawdb.ReadLogs(db, hash, *number, b.eth.blockchain.Config()) if logs == nil { - return nil, errors.New("failed to get logs for block") + return nil, fmt.Errorf("failed to get logs for block #%d (0x%s)", *number, hash.TerminalString()) } return logs, nil }