Skip to content

Commit

Permalink
fix: throw a custom error
Browse files Browse the repository at this point in the history
  • Loading branch information
johnletey committed Jul 4, 2022
1 parent abd671a commit 88f0db3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions x/gov/keeper/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAdd
}

// Check if deposit is enough.
// TODO: Return an error message.
depositParams := keeper.GetDepositParams(ctx)
minDepositAmount := proposal.GetMinDepositFromParams(depositParams)

Expand All @@ -129,7 +128,7 @@ func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAdd
}

if !depositAmount.IsAllGTE(adjustedMinDeposit) {
return false, nil
return false, sdkerrors.Wrapf(types.ErrInvalidDeposit, "%s", depositAmount.String())
}

// update the governance module's account coins pool
Expand Down
1 change: 1 addition & 0 deletions x/gov/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ var (
ErrInvalidVote = sdkerrors.Register(ModuleName, 7, "invalid vote option")
ErrInvalidGenesis = sdkerrors.Register(ModuleName, 8, "invalid genesis state")
ErrNoProposalHandlerExists = sdkerrors.Register(ModuleName, 9, "no handler exists for proposal type")
ErrInvalidDeposit = sdkerrors.Register(ModuleName, 1000, "invalid deposit amount")
)

0 comments on commit 88f0db3

Please sign in to comment.