Skip to content

Commit

Permalink
chore: simplified gorums codec errors
Browse files Browse the repository at this point in the history
  • Loading branch information
meling committed Mar 23, 2024
1 parent 907a8e7 commit d0746c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .vscode/gorums.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ protoc
protogen
protoimpl
protoreflect
protoregistry
protowire
ptypes
QCQF
qcresult
Expand All @@ -79,6 +81,7 @@ unicast
unmarshal
unmarshaled
unmarshaling
unmarshals
userguide
Xeon
Zorums
10 changes: 4 additions & 6 deletions encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c Codec) Marshal(m interface{}) (b []byte, err error) {
case protoreflect.ProtoMessage:
return c.marshaler.Marshal(msg)
default:
return nil, fmt.Errorf("gorumsCodec: don't know how to marshal message of type '%T'", m)
return nil, fmt.Errorf("gorums: cannot marshal message of type '%T'", m)
}
}

Expand Down Expand Up @@ -96,7 +96,7 @@ func (c Codec) Unmarshal(b []byte, m interface{}) (err error) {
case protoreflect.ProtoMessage:
return c.unmarshaler.Unmarshal(b, msg)
default:
return fmt.Errorf("gorumsCodec: don't know how to unmarshal message of type '%T'", m)
return fmt.Errorf("gorums: cannot unmarshal message of type '%T'", m)
}
}

Expand Down Expand Up @@ -124,7 +124,7 @@ func (c Codec) gorumsUnmarshal(b []byte, msg *Message) (err error) {
case responseType:
messageName = methodDesc.Output().FullName()
default:
return fmt.Errorf("gorumsCodec: Unknown message type")
return fmt.Errorf("gorums: unknown message type %d", msg.msgType)
}

// now get the message type from the types registry
Expand All @@ -136,7 +136,5 @@ func (c Codec) gorumsUnmarshal(b []byte, msg *Message) (err error) {

// unmarshal message
msgBuf, _ := protowire.ConsumeBytes(b[mdLen:])
err = c.unmarshaler.Unmarshal(msgBuf, msg.Message)

return err
return c.unmarshaler.Unmarshal(msgBuf, msg.Message)
}

0 comments on commit d0746c9

Please sign in to comment.