mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
eth,cmd: use errors.Is for err comparison
This commit is contained in:
parent
68de26e346
commit
27300b01ed
6 changed files with 11 additions and 9 deletions
|
|
@ -923,13 +923,13 @@ func testExternalUI(api *core.SignerAPI) {
|
|||
}
|
||||
}
|
||||
expectApprove := func(testcase string, err error) {
|
||||
if err == nil || err == accounts.ErrUnknownAccount {
|
||||
if err == nil || errors.Is(err, accounts.ErrUnknownAccount) {
|
||||
return
|
||||
}
|
||||
addErr(fmt.Sprintf("%v: expected no error, got %v", testcase, err.Error()))
|
||||
}
|
||||
expectDeny := func(testcase string, err error) {
|
||||
if err == nil || err != core.ErrRequestDenied {
|
||||
if err == nil || !errors.Is(err, core.ErrRequestDenied) {
|
||||
addErr(fmt.Sprintf("%v: expected ErrRequestDenied, got %v", testcase, err))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ func blocksFromFile(chainfile string, gblock *types.Block) ([]*types.Block, erro
|
|||
blocks[0] = gblock
|
||||
for i := 0; ; i++ {
|
||||
var b types.Block
|
||||
if err := stream.Decode(&b); err == io.EOF {
|
||||
if err := stream.Decode(&b); errors.Is(err, io.EOF) {
|
||||
break
|
||||
} else if err != nil {
|
||||
return nil, fmt.Errorf("at block index %d: %v", i, err)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package v5test
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"net"
|
||||
"slices"
|
||||
"sync"
|
||||
|
|
@ -96,7 +97,7 @@ func (s *Suite) TestPingLargeRequestID(t *utesting.T) {
|
|||
case *v5wire.Pong:
|
||||
t.Errorf("PONG response with unknown request ID %x", resp.ReqID)
|
||||
case *readError:
|
||||
if resp.err == v5wire.ErrInvalidReqID {
|
||||
if errors.Is(resp.err, v5wire.ErrInvalidReqID) {
|
||||
t.Error("response with oversized request ID")
|
||||
} else if !netutil.IsTimeout(resp.err) {
|
||||
t.Error(resp)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
"bytes"
|
||||
"container/list"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
|
|
@ -149,7 +150,7 @@ func dump(in *inStream, s *rlp.Stream, depth int, out io.Writer) error {
|
|||
if i > 0 {
|
||||
fmt.Fprint(out, ",\n")
|
||||
}
|
||||
if err := dump(in, s, depth+1, out); err == rlp.EOL {
|
||||
if err := dump(in, s, depth+1, out); errors.Is(err, rlp.EOL) {
|
||||
break
|
||||
} else if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ func ImportChain(chain *core.BlockChain, fn string) error {
|
|||
i := 0
|
||||
for ; i < importBatchSize; i++ {
|
||||
var b types.Block
|
||||
if err := stream.Decode(&b); err == io.EOF {
|
||||
if err := stream.Decode(&b); errors.Is(err, io.EOF) {
|
||||
break
|
||||
} else if err != nil {
|
||||
return fmt.Errorf("at block %d: %v", n, err)
|
||||
|
|
@ -517,7 +517,7 @@ func ImportPreimages(db ethdb.Database, fn string) error {
|
|||
var blob []byte
|
||||
|
||||
if err := stream.Decode(&blob); err != nil {
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
break
|
||||
}
|
||||
return err
|
||||
|
|
@ -727,7 +727,7 @@ func ImportLDBData(db ethdb.Database, f string, startIndex int64, interrupt chan
|
|||
key, val []byte
|
||||
)
|
||||
if err := stream.Decode(&op); err != nil {
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
break
|
||||
}
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ func (api *AdminAPI) ImportChain(file string) (bool, error) {
|
|||
// Load a batch of blocks from the input file
|
||||
for len(blocks) < cap(blocks) {
|
||||
block := new(types.Block)
|
||||
if err := stream.Decode(block); err == io.EOF {
|
||||
if err := stream.Decode(block); errors.Is(err, io.EOF) {
|
||||
break
|
||||
} else if err != nil {
|
||||
return false, fmt.Errorf("block %d: failed to parse: %v", index, err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue