Skip to content

Commit

Permalink
Merge PR cosmos#1227: Set all Error strings 1st letters to lowercase.…
Browse files Browse the repository at this point in the history
… Fixes issue cosmos#1154
  • Loading branch information
davekaj authored and cwgoes committed Jun 13, 2018
1 parent 157047c commit ec2fedd
Show file tree
Hide file tree
Showing 28 changed files with 107 additions and 107 deletions.
10 changes: 5 additions & 5 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (app *BaseApp) initFromStore(mainKey sdk.StoreKey) error {
// TODO: we don't actually need the main store here
main := app.cms.GetKVStore(mainKey)
if main == nil {
return errors.New("BaseApp expects MultiStore with 'main' KVStore")
return errors.New("baseapp expects MultiStore with 'main' KVStore")
}

// XXX: Do we really need the header? What does it have that we want
Expand All @@ -216,11 +216,11 @@ func (app *BaseApp) initFromStore(mainKey sdk.StoreKey) error {
}
err := proto.Unmarshal(headerBytes, &header)
if err != nil {
return errors.Wrap(err, "Failed to parse Header")
return errors.Wrap(err, "failed to parse Header")
}
lastVersion := lastCommitID.Version
if header.Height != lastVersion {
errStr := fmt.Sprintf("Expected db://%s.Height %v but got %v", dbHeaderKey, lastVersion, header.Height)
errStr := fmt.Sprintf("expected db://%s.Height %v but got %v", dbHeaderKey, lastVersion, header.Height)
return errors.New(errStr)
}
}
Expand Down Expand Up @@ -468,10 +468,10 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk
if r := recover(); r != nil {
switch r.(type) {
case sdk.ErrorOutOfGas:
log := fmt.Sprintf("Out of gas in location: %v", r.(sdk.ErrorOutOfGas).Descriptor)
log := fmt.Sprintf("out of gas in location: %v", r.(sdk.ErrorOutOfGas).Descriptor)
result = sdk.ErrOutOfGas(log).Result()
default:
log := fmt.Sprintf("Recovered: %v\nstack:\n%v", r, string(debug.Stack()))
log := fmt.Sprintf("recovered: %v\nstack:\n%v", r, string(debug.Stack()))
result = sdk.ErrInternal(log).Result()
}
}
Expand Down
16 changes: 8 additions & 8 deletions client/context/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func (ctx CoreContext) BroadcastTx(tx []byte) (*ctypes.ResultBroadcastTxCommit,
}

if res.CheckTx.Code != uint32(0) {
return res, errors.Errorf("CheckTx failed: (%d) %s",
return res, errors.Errorf("checkTx failed: (%d) %s",
res.CheckTx.Code,
res.CheckTx.Log)
}
if res.DeliverTx.Code != uint32(0) {
return res, errors.Errorf("DeliverTx failed: (%d) %s",
return res, errors.Errorf("deliverTx failed: (%d) %s",
res.DeliverTx.Code,
res.DeliverTx.Log)
}
Expand Down Expand Up @@ -75,7 +75,7 @@ func (ctx CoreContext) query(key cmn.HexBytes, storeName, endPath string) (res [
}
resp := result.Response
if resp.Code != uint32(0) {
return res, errors.Errorf("Query failed: (%d) %s", resp.Code, resp.Log)
return res, errors.Errorf("query failed: (%d) %s", resp.Code, resp.Log)
}
return resp.Value, nil
}
Expand All @@ -95,7 +95,7 @@ func (ctx CoreContext) GetFromAddress() (from sdk.Address, err error) {

info, err := keybase.Get(name)
if err != nil {
return nil, errors.Errorf("No key for: %s", name)
return nil, errors.Errorf("no key for: %s", name)
}

return info.PubKey.Address(), nil
Expand All @@ -107,7 +107,7 @@ func (ctx CoreContext) SignAndBuild(name, passphrase string, msg sdk.Msg, cdc *w
// build the Sign Messsage from the Standard Message
chainID := ctx.ChainID
if chainID == "" {
return nil, errors.Errorf("Chain ID required but not specified")
return nil, errors.Errorf("chain ID required but not specified")
}
accnum := ctx.AccountNumber
sequence := ctx.Sequence
Expand Down Expand Up @@ -174,7 +174,7 @@ func (ctx CoreContext) EnsureSignBuildBroadcast(name string, msg sdk.Msg, cdc *w
// get the next sequence for the account address
func (ctx CoreContext) GetAccountNumber(address []byte) (int64, error) {
if ctx.Decoder == nil {
return 0, errors.New("AccountDecoder required but not provided")
return 0, errors.New("accountDecoder required but not provided")
}

res, err := ctx.Query(auth.AddressStoreKey(address), ctx.AccountStore)
Expand All @@ -198,7 +198,7 @@ func (ctx CoreContext) GetAccountNumber(address []byte) (int64, error) {
// get the next sequence for the account address
func (ctx CoreContext) NextSequence(address []byte) (int64, error) {
if ctx.Decoder == nil {
return 0, errors.New("AccountDecoder required but not provided")
return 0, errors.New("accountDecoder required but not provided")
}

res, err := ctx.Query(auth.AddressStoreKey(address), ctx.AccountStore)
Expand Down Expand Up @@ -229,7 +229,7 @@ func (ctx CoreContext) GetPassphraseFromStdin(name string) (pass string, err err
// GetNode prepares a simple rpc.Client
func (ctx CoreContext) GetNode() (rpcclient.Client, error) {
if ctx.Client == nil {
return nil, errors.New("Must define node URI")
return nil, errors.New("must define node URI")
}
return ctx.Client, nil
}
4 changes: 2 additions & 2 deletions client/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func GetPassword(prompt string, buf *bufio.Reader) (pass string, err error) {
return "", err
}
if len(pass) < MinPassLength {
return "", errors.Errorf("Password must be at least %d characters", MinPassLength)
return "", errors.Errorf("password must be at least %d characters", MinPassLength)
}
return pass, nil
}
Expand Down Expand Up @@ -68,7 +68,7 @@ func GetCheckPassword(prompt, prompt2 string, buf *bufio.Reader) (string, error)
return "", err
}
if pass != pass2 {
return "", errors.New("Passphrases don't match")
return "", errors.New("passphrases don't match")
}
return pass, nil
}
Expand Down
2 changes: 1 addition & 1 deletion client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func runAddCmd(cmd *cobra.Command, args []string) error {
name = "inmemorykey"
} else {
if len(args) != 1 || len(args[0]) == 0 {
return errors.New("You must provide a name for the key")
return errors.New("you must provide a name for the key")
}
name = args[0]
kb, err = GetKeyBase()
Expand Down
2 changes: 1 addition & 1 deletion client/lcd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func ServeCommand(cdc *wire.Codec) *cobra.Command {
// Wait forever and cleanup
cmn.TrapSignal(func() {
err := listener.Close()
logger.Error("Error closing listener", "err", err)
logger.Error("error closing listener", "err", err)
})
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (

// XXX: remove this when not needed
func todoNotImplemented(_ *cobra.Command, _ []string) error {
return errors.New("TODO: Command not yet implemented")
return errors.New("todo: Command not yet implemented")
}

// AddCommands adds a number of rpc-related subcommands
Expand Down
2 changes: 1 addition & 1 deletion client/tx/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func SearchTxCmd(cdc *wire.Codec) *cobra.Command {

func searchTxs(ctx context.CoreContext, cdc *wire.Codec, tags []string) ([]txInfo, error) {
if len(tags) == 0 {
return nil, errors.New("Must declare at least one tag to search")
return nil, errors.New("must declare at least one tag to search")
}
// XXX: implement ANY
query := strings.Join(tags, " AND ")
Expand Down
2 changes: 1 addition & 1 deletion cmd/gaia/app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func GaiaAppGenTx(cdc *wire.Codec, pk crypto.PubKey) (
overwrite := viper.GetBool(flagOWK)
name := viper.GetString(flagName)
if name == "" {
return nil, nil, tmtypes.GenesisValidator{}, errors.New("Must specify --name (validator moniker)")
return nil, nil, tmtypes.GenesisValidator{}, errors.New("must specify --name (validator moniker)")
}

var addr sdk.Address
Expand Down
2 changes: 1 addition & 1 deletion examples/democoin/x/cool/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ const (

// ErrIncorrectCoolAnswer - Error returned upon an incorrect guess
func ErrIncorrectCoolAnswer(codespace sdk.CodespaceType, answer string) sdk.Error {
return sdk.NewError(codespace, CodeIncorrectCoolAnswer, fmt.Sprintf("Incorrect cool answer: %v", answer))
return sdk.NewError(codespace, CodeIncorrectCoolAnswer, fmt.Sprintf("incorrect cool answer: %v", answer))
}
16 changes: 8 additions & 8 deletions examples/democoin/x/pow/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ const (
func codeToDefaultMsg(code CodeType) string {
switch code {
case CodeInvalidDifficulty:
return "Insuffient difficulty"
return "insuffient difficulty"
case CodeNonexistentDifficulty:
return "Nonexistent difficulty"
return "nonexistent difficulty"
case CodeNonexistentReward:
return "Nonexistent reward"
return "nonexistent reward"
case CodeNonexistentCount:
return "Nonexistent count"
return "nonexistent count"
case CodeInvalidProof:
return "Invalid proof"
return "invalid proof"
case CodeNotBelowTarget:
return "Not below target"
return "not below target"
case CodeInvalidCount:
return "Invalid count"
return "invalid count"
case CodeUnknownRequest:
return "Unknown request"
return "unknown request"
default:
return sdk.CodeToDefaultMsg(code)
}
Expand Down
2 changes: 1 addition & 1 deletion server/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func ExportCmd(ctx *Context, cdc *wire.Codec, appExporter AppExporter) *cobra.Co
home := viper.GetString("home")
appState, validators, err := appExporter(home, ctx.Logger)
if err != nil {
return errors.Errorf("Error exporting state: %v\n", err)
return errors.Errorf("error exporting state: %v\n", err)
}
doc, err := tmtypes.GenesisDocFromFile(ctx.Config.GenesisFile())
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
"github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/proxy"
pvm "github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"
cmn "github.com/tendermint/tmlibs/common"
)

Expand Down Expand Up @@ -55,7 +55,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 errors.Errorf("error creating listener: %v\n", err)
}
svr.SetLogger(ctx.Logger.With("module", "abci-server"))
svr.Start()
Expand Down
2 changes: 1 addition & 1 deletion server/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestStartStandAlone(t *testing.T) {
svrAddr, _, err := FreeTCPAddr()
require.Nil(t, err)
svr, err := server.NewServer(svrAddr, "socket", app)
require.Nil(t, err, "Error creating listener")
require.Nil(t, err, "error creating listener")
svr.SetLogger(logger.With("module", "abci-server"))
svr.Start()

Expand Down
10 changes: 5 additions & 5 deletions store/rootmultistore.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (rs *rootMultiStore) LoadVersion(ver int64) error {
id := CommitID{}
store, err := rs.loadCommitStoreFromParams(id, storeParams)
if err != nil {
return fmt.Errorf("Failed to load rootMultiStore: %v", err)
return fmt.Errorf("failed to load rootMultiStore: %v", err)
}
rs.stores[key] = store
}
Expand All @@ -112,15 +112,15 @@ func (rs *rootMultiStore) LoadVersion(ver int64) error {
storeParams := rs.storesParams[key]
store, err := rs.loadCommitStoreFromParams(commitID, storeParams)
if err != nil {
return fmt.Errorf("Failed to load rootMultiStore: %v", err)
return fmt.Errorf("failed to load rootMultiStore: %v", err)
}
newStores[key] = store
}

// If any CommitStoreLoaders were not used, return error.
for key := range rs.storesParams {
if _, ok := newStores[key]; !ok {
return fmt.Errorf("Unused CommitStoreLoader: %v", key)
return fmt.Errorf("unused CommitStoreLoader: %v", key)
}
}

Expand Down Expand Up @@ -399,14 +399,14 @@ func getCommitInfo(db dbm.DB, ver int64) (commitInfo, error) {
cInfoKey := fmt.Sprintf(commitInfoKeyFmt, ver)
cInfoBytes := db.Get([]byte(cInfoKey))
if cInfoBytes == nil {
return commitInfo{}, fmt.Errorf("Failed to get rootMultiStore: no data")
return commitInfo{}, fmt.Errorf("failed to get rootMultiStore: no data")
}

// Parse bytes.
var cInfo commitInfo
err := cdc.UnmarshalBinary(cInfoBytes, &cInfo)
if err != nil {
return commitInfo{}, fmt.Errorf("Failed to get rootMultiStore: %v", err)
return commitInfo{}, fmt.Errorf("failed to get rootMultiStore: %v", err)
}
return cInfo, nil
}
Expand Down
2 changes: 1 addition & 1 deletion types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func GetFromBech32(bech32str, prefix string) ([]byte, error) {
}

if hrp != prefix {
return nil, fmt.Errorf("Invalid bech32 prefix. Expected %s, Got %s", prefix, hrp)
return nil, fmt.Errorf("invalid bech32 prefix. Expected %s, Got %s", prefix, hrp)
}

return bz, nil
Expand Down
4 changes: 2 additions & 2 deletions types/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func ParseCoin(coinStr string) (coin Coin, err error) {

matches := reCoin.FindStringSubmatch(coinStr)
if matches == nil {
err = fmt.Errorf("Invalid coin expression: %s", coinStr)
err = fmt.Errorf("invalid coin expression: %s", coinStr)
return
}
denomStr, amountStr := matches[2], matches[1]
Expand Down Expand Up @@ -316,7 +316,7 @@ func ParseCoins(coinsStr string) (coins Coins, err error) {

// Validate coins before returning.
if !coins.IsValid() {
return nil, fmt.Errorf("ParseCoins invalid: %#v", coins)
return nil, fmt.Errorf("parseCoins invalid: %#v", coins)
}

return coins, nil
Expand Down
28 changes: 14 additions & 14 deletions types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,31 @@ const (
func CodeToDefaultMsg(code CodeType) string {
switch code {
case CodeInternal:
return "Internal error"
return "internal error"
case CodeTxDecode:
return "Tx parse error"
return "tx parse error"
case CodeInvalidSequence:
return "Invalid sequence"
return "invalid sequence"
case CodeUnauthorized:
return "Unauthorized"
return "unauthorized"
case CodeInsufficientFunds:
return "Insufficent funds"
return "insufficent funds"
case CodeUnknownRequest:
return "Unknown request"
return "unknown request"
case CodeInvalidAddress:
return "Invalid address"
return "invalid address"
case CodeInvalidPubKey:
return "Invalid pubkey"
return "invalid pubkey"
case CodeUnknownAddress:
return "Unknown address"
return "unknown address"
case CodeInsufficientCoins:
return "Insufficient coins"
return "insufficient coins"
case CodeInvalidCoins:
return "Invalid coins"
return "invalid coins"
case CodeOutOfGas:
return "Out of gas"
return "out of gas"
default:
return fmt.Sprintf("Unknown code %d", code)
return fmt.Sprintf("unknown code %d", code)
}
}

Expand Down Expand Up @@ -183,7 +183,7 @@ type sdkError struct {

// Implements ABCIError.
func (err *sdkError) Error() string {
return fmt.Sprintf("Error{%d:%d,%#v}", err.codespace, err.code, err.err)
return fmt.Sprintf("error{%d:%d,%#v}", err.codespace, err.code, err.err)
}

// Implements ABCIError.
Expand Down
6 changes: 3 additions & 3 deletions x/auth/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func QueryAccountRequestHandlerFn(storeName string, cdc *wire.Codec, decoder aut
res, err := ctx.Query(auth.AddressStoreKey(addr), storeName)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(fmt.Sprintf("Could't query account. Error: %s", err.Error())))
w.Write([]byte(fmt.Sprintf("couldn't query account. Error: %s", err.Error())))
return
}

Expand All @@ -51,15 +51,15 @@ func QueryAccountRequestHandlerFn(storeName string, cdc *wire.Codec, decoder aut
account, err := decoder(res)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(fmt.Sprintf("Could't parse query result. Result: %s. Error: %s", res, err.Error())))
w.Write([]byte(fmt.Sprintf("couldn't parse query result. Result: %s. Error: %s", res, err.Error())))
return
}

// print out whole account
output, err := cdc.MarshalJSON(account)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(fmt.Sprintf("Could't marshall query result. Error: %s", err.Error())))
w.Write([]byte(fmt.Sprintf("couldn't marshall query result. Error: %s", err.Error())))
return
}

Expand Down
Loading

0 comments on commit ec2fedd

Please sign in to comment.