chore(all): replace all fmt.Errorf without paramters with errors.New (#21068)

This commit is contained in:
yukionfire
2024-07-25 14:54:49 +02:00
committed by GitHub
parent 6a2d039e12
commit d6ad92db0f
57 changed files with 127 additions and 103 deletions
+1 -1
View File
@@ -290,7 +290,7 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err
if keyType == keyring.TypeLedger && clientCtx.SignModeStr == flags.SignModeTextual {
if !slices.Contains(clientCtx.TxConfig.SignModeHandler().SupportedModes(), signingv1beta1.SignMode_SIGN_MODE_TEXTUAL) {
return clientCtx, fmt.Errorf("SIGN_MODE_TEXTUAL is not available")
return clientCtx, errors.New("SIGN_MODE_TEXTUAL is not available")
}
}
+2 -2
View File
@@ -2,7 +2,7 @@ package client
import (
gocontext "context"
"fmt"
"errors"
"reflect"
"strconv"
@@ -123,7 +123,7 @@ func (ctx Context) Invoke(grpcCtx gocontext.Context, method string, req, reply i
// NewStream implements the grpc ClientConn.NewStream method
func (Context) NewStream(gocontext.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) {
return nil, fmt.Errorf("streaming rpc not supported")
return nil, errors.New("streaming rpc not supported")
}
// gRPCCodec checks if Context's Codec is codec.GRPCCodecProvider
+2 -2
View File
@@ -102,12 +102,12 @@ func LoadArchiveCmd() *cobra.Command {
savedSnapshot := <-quitChan
if savedSnapshot == nil {
return fmt.Errorf("failed to save snapshot")
return errors.New("failed to save snapshot")
}
if !reflect.DeepEqual(&snapshot, savedSnapshot) {
_ = snapshotStore.Delete(snapshot.Height, snapshot.Format)
return fmt.Errorf("invalid archive, the saved snapshot is not equal to the original one")
return errors.New("invalid archive, the saved snapshot is not equal to the original one")
}
return nil
+1 -1
View File
@@ -441,7 +441,7 @@ func (f Factory) BuildSimTx(msgs ...sdk.Msg) ([]byte, error) {
encoder := f.txConfig.TxEncoder()
if encoder == nil {
return nil, fmt.Errorf("cannot simulate tx: tx encoder is nil")
return nil, errors.New("cannot simulate tx: tx encoder is nil")
}
return encoder(txb.GetTx())
+2 -1
View File
@@ -2,6 +2,7 @@ package tx
import (
"context"
"errors"
"fmt"
"strings"
"testing"
@@ -44,7 +45,7 @@ type mockContext struct {
func (m mockContext) Invoke(_ context.Context, _ string, _, reply interface{}, _ ...grpc.CallOption) (err error) {
if m.wantErr {
return fmt.Errorf("mock err")
return errors.New("mock err")
}
*(reply.(*txtypes.SimulateResponse)) = txtypes.SimulateResponse{
+2 -2
View File
@@ -2,7 +2,7 @@ package flag
import (
"context"
"fmt"
"errors"
"strings"
"google.golang.org/protobuf/reflect/protoreflect"
@@ -38,7 +38,7 @@ func (c *coinValue) String() string {
func (c *coinValue) Set(stringValue string) error {
if strings.Contains(stringValue, ",") {
return fmt.Errorf("coin flag must be a single coin, specific multiple coins with multiple flags or spaces")
return errors.New("coin flag must be a single coin, specific multiple coins with multiple flags or spaces")
}
coin, err := coins.ParseCoin(stringValue)
+3 -3
View File
@@ -1,7 +1,7 @@
package coins
import (
"fmt"
"errors"
"regexp"
"strings"
@@ -19,13 +19,13 @@ func ParseCoin(input string) (*basev1beta1.Coin, error) {
input = strings.TrimSpace(input)
if input == "" {
return nil, fmt.Errorf("empty input when parsing coin")
return nil, errors.New("empty input when parsing coin")
}
matches := coinRegex.FindStringSubmatch(input)
if len(matches) == 0 {
return nil, fmt.Errorf("invalid input format")
return nil, errors.New("invalid input format")
}
return &basev1beta1.Coin{
+2 -1
View File
@@ -1,6 +1,7 @@
package prompt
import (
"errors"
"fmt"
"net/url"
@@ -10,7 +11,7 @@ import (
// ValidatePromptNotEmpty validates that the input is not empty.
func ValidatePromptNotEmpty(input string) error {
if input == "" {
return fmt.Errorf("input cannot be empty")
return errors.New("input cannot be empty")
}
return nil
+1 -1
View File
@@ -123,7 +123,7 @@ func verifySignature(
return err
}
if !pubKey.VerifySignature(signBytes, data.Signature) {
return fmt.Errorf("unable to verify single signer signature")
return errors.New("unable to verify single signer signature")
}
return nil
default: