From cbcbe5eb43793e2b8207c0587acb0b6a23da9ba0 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sat, 11 May 2013 02:23:45 -0500 Subject: [PATCH] Convert MsgVersion errors to MessageError type. --- msgversion.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/msgversion.go b/msgversion.go index d9b13e37..5330ca66 100644 --- a/msgversion.go +++ b/msgversion.go @@ -95,8 +95,9 @@ func (msg *MsgVersion) BtcDecode(r io.Reader, pver uint32) error { return err } if len(userAgent) > MaxUserAgentLen { - str := "MsgVersion.BtcDecode: user agent too long [max %v]" - return fmt.Errorf(str, MaxUserAgentLen) + str := fmt.Sprintf("user agent too long [len %v, max %v]", + len(userAgent), MaxUserAgentLen) + return messageError("MsgVersion.BtcDecode", str) } msg.UserAgent = userAgent @@ -112,8 +113,9 @@ func (msg *MsgVersion) BtcDecode(r io.Reader, pver uint32) error { // This is part of the Message interface implementation. func (msg *MsgVersion) BtcEncode(w io.Writer, pver uint32) error { if len(msg.UserAgent) > MaxUserAgentLen { - str := "MsgVersion.BtcEncode: user agent too long [max %v]" - return fmt.Errorf(str, MaxUserAgentLen) + str := fmt.Sprintf("user agent too long [len %v, max %v]", + len(msg.UserAgent), MaxUserAgentLen) + return messageError("MsgVersion.BtcEncode", str) } err := writeElements(w, msg.ProtocolVersion, msg.Services,