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 cp-wjhan committed Nov 28, 2022
1 parent d5e9048 commit a4155a9
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 @@ -189,11 +190,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 a4155a9

Please sign in to comment.