170 | @@ -171,7 +171,7 @@ def _on_data(self):
171 | if len(self.recvbuf) < 4:
172 | return
173 | if self.recvbuf[:4] != self.magic_bytes:
174 | - raise ValueError("got garbage %s" % repr(self.recvbuf))
175 | + raise ValueError("magic bytes mismatch: {} != {}".format(repr(self.magic_bytes), repr(self.recvbuf)))
raise ValueError("magic bytes mismatch: {} != {}".format(repr(self.magic_bytes), repr(self.recvbuf[:4])))
Would still be nice to see the message type
That's a good point. Reverting my suggestion :-)
raise ValueError("magic bytes mismatch: received {} which does not start with the expected {}".format(repr(self.recvbuf), repr(self.magic_bytes)))
Was going to suggest something like this.