code: def message_iter(evt):
          
          for msg in evt:
              if logger.isEnabledFor(log.logging.DEBUG):
                  logger.debug(msg.toString())
              if msg.asElement().hasElement('responseError'):
                  raise Exception(msg.toString())
              yield msg
docs: provide a message iterator which checks for a response error prior to returning