]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Try to print something useful for MessageType panics
authorMatt Joiner <anacrolix@gmail.com>
Fri, 2 Feb 2018 10:52:57 +0000 (21:52 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 2 Feb 2018 10:52:57 +0000 (21:52 +1100)
peer_protocol/protocol.go

index 8f914591111d4afdfdb1b0fe12a19a933c69f18c..13d76def401226910ac9aa8232f9500aaabc369e 100644 (file)
@@ -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