def _decode_error(packet, packet_buff, offset):
 if (len(packet_buff) < (offset + 3)):
  raise InvalidPacketException((u'ERROR packet too small (<%s): %s' % ((offset + 3), hexlify(packet_buff))))
 (error_code,) = struct.unpack_from('!H', packet_buff, offset)
 (error_msg, idx) = _get_string(packet_buff, (offset + 2))
 if (not error_msg):
  raise InvalidPacketException((u'ERROR packet has empty error message: %s' % hexlify(packet_buff)))
 if (idx != len(packet_buff)):
  raise InvalidPacketException((u'Invalid ERROR packet: %s' % hexlify(packet_buff)))
 packet['error_code'] = error_code
 packet['error_msg'] = error_msg
 return packet

def _decode_error ( packet , packet_buff , offset ) : if ( len ( packet_buff ) < ( offset + 3 ) ) : raise InvalidPacketException ( ( u'ERROR packet too small (<%s): %s' % ( ( offset + 3 ) , hexlify ( packet_buff ) ) ) ) ( error_code , ) = struct . unpack_from ( '!H' , packet_buff , offset ) ( error_msg , idx ) = _get_string ( packet_buff , ( offset + 2 ) ) if ( not error_msg ) : raise InvalidPacketException ( ( u'ERROR packet has empty error message: %s' % hexlify ( packet_buff ) ) ) if ( idx != len ( packet_buff ) ) : raise InvalidPacketException ( ( u'Invalid ERROR packet: %s' % hexlify ( packet_buff ) ) ) packet [ 'error_code' ] = error_code packet [ 'error_msg' ] = error_msg return packet
decodes a error packet .