Skip to content

Commit

Permalink
eth: clarify the error string on getlogs failure (ethereum#24617)
Browse files Browse the repository at this point in the history
This PR makes the errors we spit out a bit more clear about what block is problematic.
  • Loading branch information
holiman authored and jagdeep sidhu committed Apr 3, 2022
1 parent 5e9fc68 commit 1c7670d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package eth
import (
"context"
"errors"
"fmt"
"math/big"
"time"

Expand Down Expand Up @@ -190,11 +191,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
}
Expand Down

0 comments on commit 1c7670d

Please sign in to comment.