From 92f20f9794a5784a495ce9ca24a9cd4707a365b2 Mon Sep 17 00:00:00 2001 From: yukionfire Date: Mon, 9 Sep 2024 14:50:03 +0800 Subject: [PATCH] chore(all): replace all `fmt.Errorf` without paramters with `errors.New` (#21590) --- indexer/postgres/params.go | 5 +++-- server/v2/cometbft/commands.go | 2 +- x/bank/v2/keeper/query_server.go | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/indexer/postgres/params.go b/indexer/postgres/params.go index b2af8f6f17..ea7a1d486e 100644 --- a/indexer/postgres/params.go +++ b/indexer/postgres/params.go @@ -1,6 +1,7 @@ package postgres import ( + "errors" "fmt" "time" @@ -18,7 +19,7 @@ func (tm *objectIndexer) bindKeyParams(key interface{}) ([]interface{}, []string } else { key, ok := key.([]interface{}) if !ok { - return nil, nil, fmt.Errorf("expected key to be a slice") + return nil, nil, errors.New("expected key to be a slice") } return tm.bindParams(tm.typ.KeyFields, key) @@ -55,7 +56,7 @@ func (tm *objectIndexer) bindValueParams(value interface{}) (params []interface{ } else { values, ok := value.([]interface{}) if !ok { - return nil, nil, fmt.Errorf("expected values to be a slice") + return nil, nil, errors.New("expected values to be a slice") } return tm.bindParams(tm.typ.ValueFields, values) diff --git a/server/v2/cometbft/commands.go b/server/v2/cometbft/commands.go index 49be1c969a..08b1add378 100644 --- a/server/v2/cometbft/commands.go +++ b/server/v2/cometbft/commands.go @@ -33,7 +33,7 @@ func rpcClient(cmd *cobra.Command) (rpc.CometRPC, error) { return nil, err } if rpcURI == "" { - return nil, fmt.Errorf("rpc URI is empty") + return nil, errors.New("rpc URI is empty") } return rpchttp.New(rpcURI) diff --git a/x/bank/v2/keeper/query_server.go b/x/bank/v2/keeper/query_server.go index 4577c11615..755af4a990 100644 --- a/x/bank/v2/keeper/query_server.go +++ b/x/bank/v2/keeper/query_server.go @@ -2,7 +2,7 @@ package keeper import ( "context" - "fmt" + "errors" "cosmossdk.io/x/bank/v2/types" ) @@ -21,7 +21,7 @@ func NewQuerier(k *Keeper) types.QueryServer { // Params implements types.QueryServer. func (q querier) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { if req == nil { - return nil, fmt.Errorf("empty request") + return nil, errors.New("empty request") } params, err := q.params.Get(ctx)