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 #3398

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 3 additions & 2 deletions tm2/pkg/bft/rpc/core/blocks.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package core

import (
"errors"
"fmt"

ctypes "github.com/gnolang/gno/tm2/pkg/bft/rpc/core/types"
Expand Down Expand Up @@ -101,7 +102,7 @@ func BlockchainInfo(ctx *rpctypes.Context, minHeight, maxHeight int64) (*ctypes.
func filterMinMax(height, low, high, limit int64) (int64, int64, error) {
// filter negatives
if low < 0 || high < 0 {
return low, high, fmt.Errorf("heights must be non-negative")
return low, high, errors.New("heights must be non-negative")
}

// adjust for default values
Expand Down Expand Up @@ -428,7 +429,7 @@ func getHeightWithMin(currentHeight int64, heightPtr *int64, minVal int64) (int6
return 0, fmt.Errorf("height must be greater than or equal to %d", minVal)
}
if height > currentHeight {
return 0, fmt.Errorf("height must be less than or equal to the current blockchain height")
return 0, errors.New("height must be less than or equal to the current blockchain height")
}
return height, nil
}
Expand Down
4 changes: 2 additions & 2 deletions tm2/pkg/bft/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (b *Block) ValidateBasic() error {
return errors.New("nil LastCommit")
}
if err := b.LastCommit.ValidateBasic(); err != nil {
return fmt.Errorf("wrong LastCommit")
return errors.New("wrong LastCommit")
}
}
if err := ValidateHash(b.LastCommitHash); err != nil {
Expand Down Expand Up @@ -753,7 +753,7 @@ func (blockID BlockID) Key() string {
func (blockID BlockID) ValidateBasic() error {
// Hash can be empty in case of POLBlockID in Proposal.
if err := ValidateHash(blockID.Hash); err != nil {
return fmt.Errorf("wrong Hash")
return errors.New("wrong Hash")
}
if err := blockID.PartsHeader.ValidateBasic(); err != nil {
return fmt.Errorf("wrong PartsHeader: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion tm2/pkg/bft/wal/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ func (dec *WALReader) ReadMessage() (*TimedWALMessage, *MetaMessage, error) {
}

if len(line64) == 0 {
return nil, nil, DataCorruptionError{fmt.Errorf("found empty line")}
return nil, nil, DataCorruptionError{errors.New("found empty line")}
}

// special case for MetaMessage.
Expand Down
Loading