Skip to content

Commit

Permalink
improve error handling for contract manager
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverHappened committed Oct 28, 2024
1 parent 973d3c4 commit 4066415
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion wasmbinding/test/custom_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ func (suite *CustomMessengerTestSuite) TestResubmitFailureFromDifferentContract(

// Dispatch
_, err = suite.executeNeutronMsg(suite.contractAddress, msg)
suite.ErrorContains(err, "no failure found to resubmit: not found")
suite.ErrorContains(err, "no failure with given FailureId found to resubmit: not found")
}

func (suite *CustomMessengerTestSuite) executeCustomMsg(contractAddress sdk.AccAddress, fullMsg json.RawMessage) (data []byte, err error) {
Expand Down
4 changes: 2 additions & 2 deletions x/contractmanager/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ func (k Keeper) ResubmitFailure(goCtx context.Context, req *types.MsgResubmitFai
}

if !k.wasmKeeper.HasContractInfo(ctx, sender) {
return nil, errors.Wrap(sdkerrors.ErrNotFound, "not a contract address tried to resubmit")
return nil, errors.Wrap(types.ErrNotContractResubmission, "sender in resubmit request is not a smart contract")
}

failure, err := k.GetFailure(ctx, sender, req.FailureId)
if err != nil {
return nil, errors.Wrap(sdkerrors.ErrNotFound, "no failure found to resubmit")
return nil, errors.Wrap(sdkerrors.ErrNotFound, "no failure with given FailureId found to resubmit")
}

if err := k.resubmitFailure(ctx, sender, failure); err != nil {
Expand Down
1 change: 1 addition & 0 deletions x/contractmanager/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ var (
ErrIncorrectFailureToResubmit = errors.Register(ModuleName, 1101, "incorrect failure to resubmit")
ErrFailedToResubmitFailure = errors.Register(ModuleName, 1102, "failed to resubmit failure")
ErrSudoOutOfGas = errors.Register(ModuleName, 1103, "sudo handling went beyond the gas limit allowed by the module")
ErrNotContractResubmission = errors.Register(ModuleName, 1104, "failures resubmission is only allowed to be called by a smart contract")
)

0 comments on commit 4066415

Please sign in to comment.