Skip to content

Commit

Permalink
chore: use errors.New to replace fmt.Errorf with no parameters
Browse files Browse the repository at this point in the history
Signed-off-by: RiceChuan <[email protected]>
  • Loading branch information
RiceChuan committed Dec 24, 2024
1 parent bf83422 commit 8ff7207
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
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
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
4 changes: 2 additions & 2 deletions rpc/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,12 @@ func (c *Client) GenesisChunked(_ context.Context, id uint) (*ctypes.ResultGenes
return nil, fmt.Errorf("while creating chunks of the genesis document: %w", err)
}
if genChunks == nil {
return nil, fmt.Errorf("service configuration error, genesis chunks are not initialized")
return nil, errors.New("service configuration error, genesis chunks are not initialized")
}

chunkLen := len(genChunks)
if chunkLen == 0 {
return nil, fmt.Errorf("service configuration error, there are no chunks")
return nil, errors.New("service configuration error, there are no chunks")
}

// it's safe to do uint(chunkLen)-1 (no overflow) since we always have at least one chunk here
Expand Down

0 comments on commit 8ff7207

Please sign in to comment.