-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor Error Message Cleanup #3691
Changes from all commits
d1a8f32
e4a7330
3c4a775
76af272
5cd1c1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package auth | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/tendermint/tendermint/crypto" | ||
|
||
codec "github.com/cosmos/cosmos-sdk/codec" | ||
|
@@ -143,7 +145,7 @@ func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, process func(Account) ( | |
func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (crypto.PubKey, sdk.Error) { | ||
acc := ak.GetAccount(ctx, addr) | ||
if acc == nil { | ||
return nil, sdk.ErrUnknownAddress(addr.String()) | ||
return nil, sdk.ErrUnknownAddress(fmt.Sprintf("account %s does not exist", addr)) | ||
} | ||
return acc.GetPubKey(), nil | ||
} | ||
|
@@ -152,15 +154,15 @@ func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (crypto. | |
func (ak AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (uint64, sdk.Error) { | ||
acc := ak.GetAccount(ctx, addr) | ||
if acc == nil { | ||
return 0, sdk.ErrUnknownAddress(addr.String()) | ||
return 0, sdk.ErrUnknownAddress(fmt.Sprintf("account %s does not exist", addr)) | ||
} | ||
return acc.GetSequence(), nil | ||
} | ||
|
||
func (ak AccountKeeper) setSequence(ctx sdk.Context, addr sdk.AccAddress, newSequence uint64) sdk.Error { | ||
acc := ak.GetAccount(ctx, addr) | ||
if acc == nil { | ||
return sdk.ErrUnknownAddress(addr.String()) | ||
return sdk.ErrUnknownAddress(fmt.Sprintf("account %s does not exist", addr)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, but that would be break the general convention of these error functions where they all just take a simple There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, not really crazy about that pattern. It seems to leave a lot of subtly different errors for the same issues. I think we should standardize these, but that may be out of the scope of the PR. |
||
} | ||
|
||
if err := acc.SetSequence(newSequence); err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package querier | ||
|
||
import ( | ||
"fmt" | ||
|
||
abci "github.com/tendermint/tendermint/abci/types" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
|
@@ -142,7 +144,7 @@ func queryValidator(ctx sdk.Context, cdc *codec.Codec, req abci.RequestQuery, k | |
|
||
errRes := cdc.UnmarshalJSON(req.Data, ¶ms) | ||
if errRes != nil { | ||
return []byte{}, sdk.ErrUnknownAddress("") | ||
return []byte{}, sdk.ErrInternal(fmt.Sprintf("failed to parse params: %s", err)) | ||
} | ||
|
||
validator, found := k.GetValidator(ctx, params.ValidatorAddr) | ||
|
@@ -162,7 +164,7 @@ func queryValidatorDelegations(ctx sdk.Context, cdc *codec.Codec, req abci.Reque | |
|
||
errRes := cdc.UnmarshalJSON(req.Data, ¶ms) | ||
if errRes != nil { | ||
return []byte{}, sdk.ErrUnknownAddress("") | ||
return []byte{}, sdk.ErrInternal(fmt.Sprintf("failed to parse params: %s", err)) | ||
} | ||
|
||
delegations := k.GetValidatorDelegations(ctx, params.ValidatorAddr) | ||
|
@@ -179,7 +181,7 @@ func queryValidatorUnbondingDelegations(ctx sdk.Context, cdc *codec.Codec, req a | |
|
||
errRes := cdc.UnmarshalJSON(req.Data, ¶ms) | ||
if errRes != nil { | ||
return []byte{}, sdk.ErrUnknownAddress("") | ||
return []byte{}, sdk.ErrInternal(fmt.Sprintf("failed to parse params: %s", err)) | ||
} | ||
|
||
unbonds := k.GetUnbondingDelegationsFromValidator(ctx, params.ValidatorAddr) | ||
|
@@ -196,7 +198,7 @@ func queryDelegatorDelegations(ctx sdk.Context, cdc *codec.Codec, req abci.Reque | |
|
||
errRes := cdc.UnmarshalJSON(req.Data, ¶ms) | ||
if errRes != nil { | ||
return []byte{}, sdk.ErrUnknownAddress("") | ||
return []byte{}, sdk.ErrInternal(fmt.Sprintf("failed to parse params: %s", err)) | ||
} | ||
|
||
delegations := k.GetAllDelegatorDelegations(ctx, params.DelegatorAddr) | ||
|
@@ -213,7 +215,7 @@ func queryDelegatorUnbondingDelegations(ctx sdk.Context, cdc *codec.Codec, req a | |
|
||
errRes := cdc.UnmarshalJSON(req.Data, ¶ms) | ||
if errRes != nil { | ||
return []byte{}, sdk.ErrUnknownAddress("") | ||
return []byte{}, sdk.ErrInternal(fmt.Sprintf("failed to parse params: %s", err)) | ||
} | ||
|
||
unbondingDelegations := k.GetAllUnbondingDelegations(ctx, params.DelegatorAddr) | ||
|
@@ -232,7 +234,7 @@ func queryDelegatorValidators(ctx sdk.Context, cdc *codec.Codec, req abci.Reques | |
|
||
errRes := cdc.UnmarshalJSON(req.Data, ¶ms) | ||
if errRes != nil { | ||
return []byte{}, sdk.ErrUnknownAddress("") | ||
return []byte{}, sdk.ErrInternal(fmt.Sprintf("failed to parse params: %s", err)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm, I'm not sure that is totally a good idea as we could have a multitude of decoding failures and we don't want a unique failure type/function for reach. Maybe |
||
} | ||
|
||
validators := k.GetDelegatorValidators(ctx, params.DelegatorAddr, stakingParams.MaxValidators) | ||
|
@@ -249,7 +251,7 @@ func queryDelegatorValidator(ctx sdk.Context, cdc *codec.Codec, req abci.Request | |
|
||
errRes := cdc.UnmarshalJSON(req.Data, ¶ms) | ||
if errRes != nil { | ||
return []byte{}, sdk.ErrUnknownAddress("") | ||
return []byte{}, sdk.ErrInternal(fmt.Sprintf("failed to parse params: %s", err)) | ||
} | ||
|
||
validator, err := k.GetDelegatorValidator(ctx, params.DelegatorAddr, params.ValidatorAddr) | ||
|
@@ -269,7 +271,7 @@ func queryDelegation(ctx sdk.Context, cdc *codec.Codec, req abci.RequestQuery, k | |
|
||
errRes := cdc.UnmarshalJSON(req.Data, ¶ms) | ||
if errRes != nil { | ||
return []byte{}, sdk.ErrUnknownAddress("") | ||
return []byte{}, sdk.ErrInternal(fmt.Sprintf("failed to parse params: %s", err)) | ||
} | ||
|
||
delegation, found := k.GetDelegation(ctx, params.DelegatorAddr, params.ValidatorAddr) | ||
|
@@ -289,7 +291,7 @@ func queryUnbondingDelegation(ctx sdk.Context, cdc *codec.Codec, req abci.Reques | |
|
||
errRes := cdc.UnmarshalJSON(req.Data, ¶ms) | ||
if errRes != nil { | ||
return []byte{}, sdk.ErrUnknownAddress("") | ||
return []byte{}, sdk.ErrInternal(fmt.Sprintf("failed to parse params: %s", err)) | ||
} | ||
|
||
unbond, found := k.GetUnbondingDelegation(ctx, params.DelegatorAddr, params.ValidatorAddr) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ref: #3693 -- this should always be valid JSON @alessio. Thoughts?
/cc @faboweb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes plz!