Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: suggest using errors.New instead of fmt.Errorf with no parameters #4822

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions eth/rpc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package rpc
import (
"context"
"encoding/json"
"errors"
"fmt"
"math"
"strings"
Expand Down Expand Up @@ -97,7 +98,7 @@ func (bn *BlockNumber) UnmarshalJSON(data []byte) error {
return err
}
if blckNum > math.MaxInt64 {
return fmt.Errorf("block number larger than int64")
return errors.New("block number larger than int64")
}
*bn = BlockNumber(blckNum)
return nil
Expand Down Expand Up @@ -135,7 +136,7 @@ func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error {
err := json.Unmarshal(data, &e)
if err == nil {
if e.BlockNumber != nil && e.BlockHash != nil {
return fmt.Errorf("cannot specify both BlockHash and BlockNumber, choose one or the other")
return errors.New("cannot specify both BlockHash and BlockNumber, choose one or the other")
}
bnh.BlockNumber = e.BlockNumber
bnh.BlockHash = e.BlockHash
Expand Down Expand Up @@ -180,7 +181,7 @@ func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error {
return err
}
if blckNum > math.MaxInt64 {
return fmt.Errorf("blocknumber too high")
return errors.New("blocknumber too high")
}
bn := BlockNumber(blckNum)
bnh.BlockNumber = &bn
Expand Down
6 changes: 3 additions & 3 deletions hmy/tracers/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,17 +428,17 @@ func New(code string) (*Tracer, error) {
tracer.tracerObject = 0 // yeah, nice, eval can't return the index itself

if !tracer.vm.GetPropString(tracer.tracerObject, "step") {
return nil, fmt.Errorf("trace object must expose a function step()")
return nil, errors.New("trace object must expose a function step()")
}
tracer.vm.Pop()

if !tracer.vm.GetPropString(tracer.tracerObject, "fault") {
return nil, fmt.Errorf("trace object must expose a function fault()")
return nil, errors.New("trace object must expose a function fault()")
}
tracer.vm.Pop()

if !tracer.vm.GetPropString(tracer.tracerObject, "result") {
return nil, fmt.Errorf("trace object must expose a function result()")
return nil, errors.New("trace object must expose a function result()")
}
tracer.vm.Pop()

Expand Down