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

refactor: use errors.New to replace fmt.Errorf with no parameters #1281

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (m *Manager) applyBlock(block *types.Block, commit *types.Commit, blockMeta
// Proposer cannot be empty while applying the block
proposer := m.State.GetProposer()
if proposer == nil {
return fmt.Errorf("logic error: got nil proposer while applying block")
return errors.New("logic error: got nil proposer while applying block")
}

batch := m.Store.NewBatch()
Expand Down
2 changes: 1 addition & 1 deletion block/modes.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (m *Manager) runAsProposer(ctx context.Context, eg *errgroup.Group) error {
return fmt.Errorf("am i proposer on SL: %w", err)
}
if !amIProposerOnSL {
return fmt.Errorf("the node is no longer the proposer. please restart.")
return errors.New("the node is no longer the proposer. please restart.")
}

// update l2 proposer from SL in case it changed after syncing
Expand Down
2 changes: 1 addition & 1 deletion block/slvalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (v *SettlementValidator) ValidateDaBlocks(slBatch *settlement.ResultRetriev
if slBatch.NextSequencer != slBatch.Sequencer {
nextSequencer, found := v.blockManager.Sequencers.GetByAddress(slBatch.NextSequencer)
if !found {
return fmt.Errorf("next sequencer not found")
return errors.New("next sequencer not found")
}
copy(expectedNextSeqHash[:], nextSequencer.MustHash())
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/dymint/commands/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -141,7 +142,7 @@ func startInProcess(config *cfg.NodeConfig, tmConfig *tmcfg.Config, logger log.L

func checkGenesisHash(config *tmcfg.Config) error {
if config.Genesis == "" {
return fmt.Errorf("genesis file is not set")
return errors.New("genesis file is not set")
}

if len(genesisHash) == 0 {
Expand Down
4 changes: 2 additions & 2 deletions da/da.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package da

import (
"encoding/hex"
"fmt"
"errors"
"strconv"
"strings"

Expand Down Expand Up @@ -113,7 +113,7 @@ func (d *DASubmitMetaData) ToPath() string {
func (d *DASubmitMetaData) FromPath(path string) (*DASubmitMetaData, error) {
pathParts := strings.FieldsFunc(path, func(r rune) bool { return r == rune(PathSeparator[0]) })
if len(pathParts) < 2 {
return nil, fmt.Errorf("invalid DA path")
return nil, errors.New("invalid DA path")
}

height, err := strconv.ParseUint(pathParts[1], 10, 64)
Expand Down
5 changes: 2 additions & 3 deletions test/loadtime/cmd/load/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package main

import (
"fmt"

"errors"
"github.com/google/uuid"
"github.com/informalsystems/tm-load-test/pkg/loadtest"

Expand Down Expand Up @@ -51,7 +50,7 @@ func (f *ClientFactory) ValidateConfig(cfg loadtest.Config) error {
return err
}
if psb > cfg.Size {
return fmt.Errorf("payload size exceeds configured size")
return errors.New("payload size exceeds configured size")
}
return nil
}
Expand Down
Loading