Skip to content

Commit

Permalink
chore: improve any compat error (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Jul 18, 2024
1 parent 6eec973 commit 89ccff4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/cosmos/gogoproto
go 1.19

require (
github.com/golang/protobuf v1.5.3
github.com/google/go-cmp v0.6.0
github.com/tendermint/go-amino v0.16.0
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
Expand All @@ -12,7 +13,6 @@ require (

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
golang.org/x/net v0.20.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion types/any/any_with_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type Any struct {
// unmarshalling
func NewAnyWithCacheWithValue(v proto.Message) (*Any, error) {
if v == nil {
return nil, errors.New("Expecting non nil value to create a new Any, failed packing protobuf message to Any")
return nil, errors.New("expecting non nil value to create a new Any, failed packing protobuf message to Any")
}

var (
Expand Down
18 changes: 9 additions & 9 deletions types/any/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ type anyCompat struct {
var Debug = true

func anyCompatError(errType string, x interface{}) error {
msg := "%s marshaling error for %+v, this is likely because " +
"amino is being used directly (instead of codec.LegacyAmino which is preferred) " +
"or UnpackInterfacesMessage is not defined for some type which contains " +
"a protobuf Any either directly or via one of its members."

if Debug {
debug.PrintStack()
} else {
msg += " To see a stacktrace of where the error is coming from, set the var Debug = true in github.com/cosmos/gogoproto/types/any/compat.go"
}
return fmt.Errorf(
"%s marshaling error for %+v, this is likely because "+
"amino is being used directly (instead of codec.LegacyAmino which is preferred) "+
"or UnpackInterfacesMessage is not defined for some type which contains "+
"a protobuf Any either directly or via one of its members. To see a "+
"stacktrace of where the error is coming from, set the var Debug = true "+
"in codec/types/compat.go",
errType, x,
)

return fmt.Errorf(msg, errType, x)
}

func (any Any) MarshalAmino() ([]byte, error) {
Expand Down

0 comments on commit 89ccff4

Please sign in to comment.