Skip to content

Commit

Permalink
Merge pull request #2 from initia-labs/feat/directly-emit-wasm-hook-e…
Browse files Browse the repository at this point in the history
…rror

feat: directly emit wasm hook error
  • Loading branch information
beer-1 authored Dec 12, 2023
2 parents 4a82285 + 7d84372 commit 9d2cf3d
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions app/ibc-middleware/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,10 @@ func jsonStringHasKey(memo, key string) (found bool, jsonObject map[string]inter

// newEmitErrorAcknowledgement creates a new error acknowledgement after having emitted an event with the
// details of the error.
func newEmitErrorAcknowledgement(ctx sdk.Context, err error, errorContexts ...string) channeltypes.Acknowledgement {
attributes := make([]sdk.Attribute, len(errorContexts)+1)
attributes[0] = sdk.NewAttribute("error", err.Error())
for i, s := range errorContexts {
attributes[i+1] = sdk.NewAttribute("error-context", s)
func newEmitErrorAcknowledgement(ctx sdk.Context, err error) channeltypes.Acknowledgement {
return channeltypes.Acknowledgement{
Response: &channeltypes.Acknowledgement_Error{
Error: fmt.Sprintf("ibc wasm hook error: %s", err.Error()),
},
}

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
"ibc-acknowledgement-error",
attributes...,
),
})

return channeltypes.NewErrorAcknowledgement(err)
}

0 comments on commit 9d2cf3d

Please sign in to comment.