From: Matt Joiner Date: Fri, 2 Feb 2018 10:52:57 +0000 (+1100) Subject: Try to print something useful for MessageType panics X-Git-Tag: v1.0.0~224 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=89b17c437264b14cbb543dba2a3aafdb8b6f401e;p=btrtrc.git Try to print something useful for MessageType panics --- diff --git a/peer_protocol/protocol.go b/peer_protocol/protocol.go index 8f914591..13d76def 100644 --- a/peer_protocol/protocol.go +++ b/peer_protocol/protocol.go @@ -1,5 +1,7 @@ package peer_protocol +import "strconv" + const ( Protocol = "\x13BitTorrent protocol" ) @@ -8,6 +10,12 @@ type ( MessageType byte ) +// Hopefully uncaught panics format using this so we don't just see a pair of +// unhelpful uintptrs. +func (me MessageType) String() string { + return strconv.FormatInt(int64(me), 10) +} + const ( Choke MessageType = iota Unchoke // 1