def exceptionFromStanza(stanza):
 children = []
 condition = text = textLang = appCondition = type = code = None
 for element in stanza.elements():
  if ((element.name == 'error') and (element.uri == stanza.uri)):
   code = element.getAttribute('code')
   type = element.getAttribute('type')
   error = _parseError(element, NS_XMPP_STANZAS)
   condition = error['condition']
   text = error['text']
   textLang = error['textLang']
   appCondition = error['appCondition']
   if ((not condition) and code):
    (condition, type) = CODES_TO_CONDITIONS[code]
    text = _getText(stanza.error)
  else:
   children.append(element)
 if (condition is None):
  return StanzaError(None)
 exception = StanzaError(condition, type, text, textLang, appCondition)
 exception.children = children
 exception.stanza = stanza
 return exception

def exceptionFromStanza ( stanza ) : children = [ ] condition = text = textLang = appCondition = type = code = None for element in stanza . elements ( ) : if ( ( element . name == 'error' ) and ( element . uri == stanza . uri ) ) : code = element . getAttribute ( 'code' ) type = element . getAttribute ( 'type' ) error = _parseError ( element , NS_XMPP_STANZAS ) condition = error [ 'condition' ] text = error [ 'text' ] textLang = error [ 'textLang' ] appCondition = error [ 'appCondition' ] if ( ( not condition ) and code ) : ( condition , type ) = CODES_TO_CONDITIONS [ code ] text = _getText ( stanza . error ) else : children . append ( element ) if ( condition is None ) : return StanzaError ( None ) exception = StanzaError ( condition , type , text , textLang , appCondition ) exception . children = children exception . stanza = stanza return exception
build an exception object from an error stanza .