def encode(self):
        try: payload = chr(self.reason)
        except __HOLE__: raise EncodeError("error reason out of limits")
        try:
            if self.reason == 1:
                payload += chr(self.data)
            elif self.reason == 2:
                payload += struct.pack(">L", self.data)
            elif self.reason == 3:
                payload += chr(self.data)
            else:
                raise EncodeError("reserved error reason %d" % self.reason)
        except (TypeError, struct.error):
            raise EncodeError("invalid data for error reason %d" % self.reason)
        return payload
    
#---------------------------------------------------------------------- Version
dataset/ETHPy150Open javgh/greenaddress-pos-tools/nfc/ndef/handover.py/HandoverError.encode