From 89b17c437264b14cbb543dba2a3aafdb8b6f401e Mon Sep 17 00:00:00 2001
From: Matt Joiner <anacrolix@gmail.com>
Date: Fri, 2 Feb 2018 21:52:57 +1100
Subject: [PATCH] Try to print something useful for MessageType panics

---
 peer_protocol/protocol.go | 8 ++++++++
 1 file changed, 8 insertions(+)

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
-- 
2.50.0