Skip to content

Commit 97f6ebf

Browse files
committed
Restructure error handling
1 parent 50a47c7 commit 97f6ebf

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

x/wasm/keeper/relay.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,18 @@ func (k Keeper) OnOpenChannel(
4040
gasLeft := k.runtimeGasForContract(ctx)
4141
res, gasUsed, execErr := k.wasmVM.IBCChannelOpen(codeInfo.CodeHash, env, msg, prefixStore, cosmwasmAPI, querier, ctx.GasMeter(), gasLeft, costJSONDeserialization)
4242
k.consumeRuntimeGas(ctx, gasUsed)
43-
switch {
44-
case execErr != nil:
43+
44+
if execErr != nil {
4545
return "", errorsmod.Wrap(types.ErrExecuteFailed, execErr.Error())
46-
case res == nil:
47-
return "", errorsmod.Wrap(types.ErrVMError, "empty response from contract")
48-
case res.Err != "":
46+
}
47+
if res == nil {
48+
// If this gets executed, that's a bug in wasmvm
49+
return "", errorsmod.Wrap(types.ErrVMError, "internal wasmvm error")
50+
}
51+
if res.Err != "" {
4952
return "", types.MarkErrorDeterministic(errorsmod.Wrap(types.ErrExecuteFailed, res.Err))
50-
case res.Ok == nil:
53+
}
54+
if res.Ok == nil {
5155
// a nil "ok" value is a valid response and means the contract accepts the incoming channel version
5256
// see https://docs.rs/cosmwasm-std/2.2.2/cosmwasm_std/type.IbcChannelOpenResponse.html
5357
return "", nil

0 commit comments

Comments
 (0)