Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ func (c Codec) gorumsUnmarshal(b []byte, msg *Message) (err error) {
mdBuf, mdLen := protowire.ConsumeBytes(b)
err = c.unmarshaler.Unmarshal(mdBuf, msg.Metadata)
if err != nil {
return err
return fmt.Errorf("gorums: could not unmarshal metadata: %w", err)
}

// get method descriptor from registry
desc, err := protoregistry.GlobalFiles.FindDescriptorByName(protoreflect.FullName(msg.Metadata.GetMethod()))
if err != nil {
return err
// err is a NotFound error with no method name information; return a more informative error
return fmt.Errorf("gorums: could not find method descriptor for %s", msg.Metadata.GetMethod())
}
methodDesc := desc.(protoreflect.MethodDescriptor)

Expand All @@ -130,7 +131,8 @@ func (c Codec) gorumsUnmarshal(b []byte, msg *Message) (err error) {
// now get the message type from the types registry
msgType, err := protoregistry.GlobalTypes.FindMessageByName(messageName)
if err != nil {
return err
// err is a NotFound error with no message name information; return a more informative error
return fmt.Errorf("gorums: could not find message type %s", messageName)
}
msg.Message = msgType.New().Interface()

Expand Down