Skip to content

Commit 5d27acd

Browse files
jsvisadevopsbo3
authored andcommitted
ethclient,event: replace noarg fmt.Errorf with errors.New (ethereum#27334)
Signed-off-by: jsvisa <delweng@gmail.com>
1 parent 13b2b9f commit 5d27acd

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

ethclient/ethclient.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,16 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface
138138
}
139139
// Quick-verify transaction and uncle lists. This mostly helps with debugging the server.
140140
if head.UncleHash == types.EmptyUncleHash && len(body.UncleHashes) > 0 {
141-
return nil, fmt.Errorf("server returned non-empty uncle list but block header indicates no uncles")
141+
return nil, errors.New("server returned non-empty uncle list but block header indicates no uncles")
142142
}
143143
if head.UncleHash != types.EmptyUncleHash && len(body.UncleHashes) == 0 {
144-
return nil, fmt.Errorf("server returned empty uncle list but block header indicates uncles")
144+
return nil, errors.New("server returned empty uncle list but block header indicates uncles")
145145
}
146146
if head.TxHash == types.EmptyTxsHash && len(body.Transactions) > 0 {
147-
return nil, fmt.Errorf("server returned non-empty transaction list but block header indicates no transactions")
147+
return nil, errors.New("server returned non-empty transaction list but block header indicates no transactions")
148148
}
149149
if head.TxHash != types.EmptyTxsHash && len(body.Transactions) == 0 {
150-
return nil, fmt.Errorf("server returned empty transaction list but block header indicates transactions")
150+
return nil, errors.New("server returned empty transaction list but block header indicates transactions")
151151
}
152152
// Load uncles because they are not included in the block response.
153153
var uncles []*types.Header
@@ -232,7 +232,7 @@ func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *
232232
} else if json == nil {
233233
return nil, false, ethereum.NotFound
234234
} else if _, r, _ := json.tx.RawSignatureValues(); r == nil {
235-
return nil, false, fmt.Errorf("server returned transaction without signature")
235+
return nil, false, errors.New("server returned transaction without signature")
236236
}
237237
if json.From != nil && json.BlockHash != nil {
238238
setSenderFromServer(json.tx, *json.From, *json.BlockHash)
@@ -284,7 +284,7 @@ func (ec *Client) TransactionInBlock(ctx context.Context, blockHash common.Hash,
284284
if json == nil {
285285
return nil, ethereum.NotFound
286286
} else if _, r, _ := json.tx.RawSignatureValues(); r == nil {
287-
return nil, fmt.Errorf("server returned transaction without signature")
287+
return nil, errors.New("server returned transaction without signature")
288288
}
289289
if json.From != nil && json.BlockHash != nil {
290290
setSenderFromServer(json.tx, *json.From, *json.BlockHash)
@@ -421,7 +421,7 @@ func toFilterArg(q ethereum.FilterQuery) (interface{}, error) {
421421
if q.BlockHash != nil {
422422
arg["blockHash"] = *q.BlockHash
423423
if q.FromBlock != nil || q.ToBlock != nil {
424-
return nil, fmt.Errorf("cannot specify both BlockHash and FromBlock/ToBlock")
424+
return nil, errors.New("cannot specify both BlockHash and FromBlock/ToBlock")
425425
}
426426
} else {
427427
if q.FromBlock == nil {

ethclient/ethclient_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"bytes"
2121
"context"
2222
"errors"
23-
"fmt"
2423
"math/big"
2524
"reflect"
2625
"testing"
@@ -55,7 +54,7 @@ var (
5554
)
5655

5756
func TestToFilterArg(t *testing.T) {
58-
blockHashErr := fmt.Errorf("cannot specify both BlockHash and FromBlock/ToBlock")
57+
blockHashErr := errors.New("cannot specify both BlockHash and FromBlock/ToBlock")
5958
addresses := []common.Address{
6059
common.HexToAddress("0xD36722ADeC3EdCB29c8e7b5a47f352D701393462"),
6160
}

event/feed_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package event
1818

1919
import (
20+
"errors"
2021
"fmt"
2122
"reflect"
2223
"sync"
@@ -68,7 +69,7 @@ func checkPanic(want error, fn func()) (err error) {
6869
defer func() {
6970
panic := recover()
7071
if panic == nil {
71-
err = fmt.Errorf("didn't panic")
72+
err = errors.New("didn't panic")
7273
} else if !reflect.DeepEqual(panic, want) {
7374
err = fmt.Errorf("panicked with wrong error: got %q, want %q", panic, want)
7475
}

0 commit comments

Comments
 (0)