Merge PR #3557: Removing pkg/errors when not necessary

This commit is contained in:
Juan Leni 2019-02-08 20:37:46 +01:00 committed by Jack Zampolin
parent 7bc837aa06
commit ba63eb1801
19 changed files with 44 additions and 42 deletions

View File

@ -7,8 +7,9 @@ import (
"runtime/debug"
"strings"
"errors"
"github.com/gogo/protobuf/proto"
"github.com/pkg/errors"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/tmhash"

View File

@ -1,7 +1,7 @@
package context
import (
"github.com/pkg/errors"
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -39,11 +39,11 @@ func (ctx CLIContext) BroadcastTxAndAwaitCommit(tx []byte) (sdk.TxResponse, erro
}
if !res.CheckTx.IsOK() {
return sdk.NewResponseFormatBroadcastTxCommit(res), errors.Errorf(res.CheckTx.Log)
return sdk.NewResponseFormatBroadcastTxCommit(res), fmt.Errorf(res.CheckTx.Log)
}
if !res.DeliverTx.IsOK() {
return sdk.NewResponseFormatBroadcastTxCommit(res), errors.Errorf(res.DeliverTx.Log)
return sdk.NewResponseFormatBroadcastTxCommit(res), fmt.Errorf(res.DeliverTx.Log)
}
return sdk.NewResponseFormatBroadcastTxCommit(res), err

View File

@ -1,7 +1,7 @@
package context
import (
"github.com/pkg/errors"
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -9,7 +9,7 @@ import (
// ErrInvalidAccount returns a standardized error reflecting that a given
// account address does not exist.
func ErrInvalidAccount(addr sdk.AccAddress) error {
return errors.Errorf(`No account with address %s was found in the state.
return fmt.Errorf(`No account with address %s was found in the state.
Are you sure there has been a transaction involving it?`, addr)
}
@ -17,6 +17,6 @@ Are you sure there has been a transaction involving it?`, addr)
// height can't be verified. The reason is that the base checkpoint of the certifier is
// newer than the given height
func ErrVerifyCommit(height int64) error {
return errors.Errorf(`The height of base truststore in gaia-lite is higher than height %d.
return fmt.Errorf(`The height of base truststore in gaia-lite is higher than height %d.
Can't verify blockchain proof at this height. Please set --trust-node to true and try again`, height)
}

View File

@ -164,7 +164,7 @@ func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, err erro
resp := result.Response
if !resp.IsOK() {
return res, errors.Errorf(resp.Log)
return res, errors.New(resp.Log)
}
// data from trusted node or subspace query doesn't need verification

View File

@ -6,9 +6,10 @@ import (
"os"
"strings"
"errors"
"github.com/bgentry/speakeasy"
"github.com/mattn/go-isatty"
"github.com/pkg/errors"
)
// MinPassLength is the minimum acceptable password length
@ -36,7 +37,7 @@ func GetPassword(prompt string, buf *bufio.Reader) (pass string, err error) {
if len(pass) < MinPassLength {
// Return the given password to the upstream client so it can handle a
// non-STDIN failure gracefully.
return pass, errors.Errorf("password must be at least %d characters", MinPassLength)
return pass, fmt.Errorf("password must be at least %d characters", MinPassLength)
}
return pass, nil

View File

@ -14,8 +14,9 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
"errors"
"github.com/gorilla/mux"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@ -297,7 +298,7 @@ func printCreate(info keys.Info, showMnemonic bool, mnemonic string) error {
}
fmt.Fprintln(os.Stderr, string(jsonString))
default:
return errors.Errorf("I can't speak: %s", output)
return fmt.Errorf("I can't speak: %s", output)
}
return nil

View File

@ -8,8 +8,9 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys"
"errors"
"github.com/gorilla/mux"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tendermint/tendermint/crypto/multisig"

View File

@ -7,7 +7,6 @@ import (
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/types"
)
@ -33,16 +32,16 @@ func ValidateGenesisCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command {
var genDoc types.GenesisDoc
if genDoc, err = LoadGenesisDoc(cdc, genesis); err != nil {
return errors.Errorf("Error loading genesis doc from %s: %s", genesis, err.Error())
return fmt.Errorf("Error loading genesis doc from %s: %s", genesis, err.Error())
}
var genstate app.GenesisState
if err = cdc.UnmarshalJSON(genDoc.AppState, &genstate); err != nil {
return errors.Errorf("Error unmarshaling genesis doc %s: %s", genesis, err.Error())
return fmt.Errorf("Error unmarshaling genesis doc %s: %s", genesis, err.Error())
}
if err = app.GaiaValidateGenesisState(genstate); err != nil {
return errors.Errorf("Error validating genesis file %s: %s", genesis, err.Error())
return fmt.Errorf("Error validating genesis file %s: %s", genesis, err.Error())
}
fmt.Printf("File at %s is a valid genesis file for gaiad\n", genesis)

View File

@ -6,7 +6,7 @@ import (
"os"
"strings"
"github.com/pkg/errors"
"errors"
"github.com/cosmos/cosmos-sdk/crypto"
"github.com/cosmos/cosmos-sdk/crypto/keys/hd"

View File

@ -3,7 +3,6 @@ package server
import (
"fmt"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@ -58,7 +57,7 @@ func ExportCmd(ctx *Context, cdc *codec.Codec, appExporter AppExporter) *cobra.C
jailWhiteList := viper.GetStringSlice(flagJailWhitelist)
appState, validators, err := appExporter(ctx.Logger, db, traceWriter, height, forZeroHeight, jailWhiteList)
if err != nil {
return errors.Errorf("error exporting state: %v\n", err)
return fmt.Errorf("error exporting state: %v", err)
}
doc, err := tmtypes.GenesisDocFromFile(ctx.Config.GenesisFile())

View File

@ -1,7 +1,8 @@
package server
import (
"github.com/pkg/errors"
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@ -76,7 +77,7 @@ func startStandAlone(ctx *Context, appCreator AppCreator) error {
svr, err := server.NewServer(addr, "socket", app)
if err != nil {
return errors.Errorf("error creating listener: %v\n", err)
return fmt.Errorf("error creating listener: %v", err)
}
svr.SetLogger(ctx.Logger.With("module", "abci-server"))

View File

@ -9,7 +9,8 @@ import (
"syscall"
"time"
"github.com/pkg/errors"
"errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"

View File

@ -1,6 +1,7 @@
package context
import (
"fmt"
"strings"
crkeys "github.com/cosmos/cosmos-sdk/crypto/keys"
@ -10,7 +11,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/pkg/errors"
"errors"
"github.com/spf13/viper"
)
@ -179,7 +181,7 @@ func (bldr TxBuilder) WithAccountNumber(accnum uint64) TxBuilder {
func (bldr TxBuilder) Build(msgs []sdk.Msg) (StdSignMsg, error) {
chainID := bldr.chainID
if chainID == "" {
return StdSignMsg{}, errors.Errorf("chain ID required but not specified")
return StdSignMsg{}, fmt.Errorf("chain ID required but not specified")
}
fees := bldr.fees

View File

@ -1,6 +1,8 @@
package cli
import (
"fmt"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/utils"
@ -9,7 +11,6 @@ import (
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@ -53,7 +54,7 @@ func SendTxCmd(cdc *codec.Codec) *cobra.Command {
// ensure account has enough coins
if !account.GetCoins().IsAllGTE(coins) {
return errors.Errorf("Address %s doesn't have enough coins to pay for this transaction.", from)
return fmt.Errorf("address %s doesn't have enough coins to pay for this transaction", from)
}
// build and sign the transaction, then broadcast to Tendermint

View File

@ -4,8 +4,6 @@ import (
"fmt"
"strconv"
"github.com/pkg/errors"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/utils"
"github.com/cosmos/cosmos-sdk/codec"
@ -101,7 +99,7 @@ $ gaiacli gov submit-proposal --title="Test Proposal" --description="My awesome
// ensure account has enough coins
if !account.GetCoins().IsAllGTE(amount) {
return errors.Errorf("Address %s doesn't have enough coins to pay for this transaction.", from)
return fmt.Errorf("address %s doesn't have enough coins to pay for this transaction", from)
}
proposalType, err := gov.ProposalTypeFromString(proposal.Type)
@ -204,7 +202,7 @@ $ gaiacli tx gov deposit 1 10stake --from mykey
// ensure account has enough coins
if !account.GetCoins().IsAllGTE(amount) {
return errors.Errorf("Address %s doesn't have enough coins to pay for this transaction.", from)
return fmt.Errorf("address %s doesn't have enough coins to pay for this transaction", from)
}
msg := gov.NewMsgDeposit(from, proposalID, amount)

View File

@ -12,8 +12,9 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
gcutils "github.com/cosmos/cosmos-sdk/x/gov/client/utils"
"errors"
"github.com/gorilla/mux"
"github.com/pkg/errors"
govClientUtils "github.com/cosmos/cosmos-sdk/x/gov/client/utils"
)

View File

@ -4,8 +4,6 @@ import (
"encoding/json"
"fmt"
"github.com/pkg/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -98,7 +96,7 @@ func VoteOptionFromString(str string) (VoteOption, error) {
case "NoWithVeto":
return OptionNoWithVeto, nil
default:
return VoteOption(0xff), errors.Errorf("'%s' is not a valid vote option", str)
return VoteOption(0xff), fmt.Errorf("'%s' is not a valid vote option", str)
}
}

View File

@ -6,8 +6,6 @@ import (
"strings"
"time"
"github.com/pkg/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -177,7 +175,7 @@ func ProposalTypeFromString(str string) (ProposalKind, error) {
case "SoftwareUpgrade":
return ProposalTypeSoftwareUpgrade, nil
default:
return ProposalKind(0xff), errors.Errorf("'%s' is not a valid proposal type", str)
return ProposalKind(0xff), fmt.Errorf("'%s' is not a valid proposal type", str)
}
}
@ -278,7 +276,7 @@ func ProposalStatusFromString(str string) (ProposalStatus, error) {
case "":
return StatusNil, nil
default:
return ProposalStatus(0xff), errors.Errorf("'%s' is not a valid proposal status", str)
return ProposalStatus(0xff), fmt.Errorf("'%s' is not a valid proposal status", str)
}
}

View File

@ -1,7 +1,7 @@
package cli
import (
"github.com/pkg/errors"
"errors"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking/types"
@ -14,7 +14,7 @@ func getShares(sharesAmountStr string, delAddr sdk.AccAddress, valAddr sdk.ValAd
}
if !sharesAmount.GT(sdk.ZeroDec()) {
return sharesAmount, errors.Errorf("shares amount must be positive number (ex. 123, 1.23456789)")
return sharesAmount, errors.New("shares amount must be positive number (ex. 123, 1.23456789)")
}
return
@ -22,7 +22,7 @@ func getShares(sharesAmountStr string, delAddr sdk.AccAddress, valAddr sdk.ValAd
func buildCommissionMsg(rateStr, maxRateStr, maxChangeRateStr string) (commission types.CommissionMsg, err error) {
if rateStr == "" || maxRateStr == "" || maxChangeRateStr == "" {
return commission, errors.Errorf("must specify all validator commission parameters")
return commission, errors.New("must specify all validator commission parameters")
}
rate, err := sdk.NewDecFromStr(rateStr)