def onStreamError(self, errelem): """ Called when a stream:error element has been received. Dispatches a L{STREAM_ERROR_EVENT} event with the error element to allow for cleanup actions and drops the connection. @param errelem: The received error element. @type errelem: L{domish.Element} """ self.dispatch(failure.Failure(error.exceptionFromStreamError(errelem)), STREAM_ERROR_EVENT) self.transport.loseConnection()
def test_basic(self): """ Test basic operations of exceptionFromStreamError. Given a realistic stream error, check if a sane exception is returned. Using this error:: <stream:error xmlns:stream='http://etherx.jabber.org/streams'> <xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/> </stream:error> """ e = domish.Element(('http://etherx.jabber.org/streams', 'error')) e.addElement((NS_XMPP_STREAMS, 'xml-not-well-formed')) result = error.exceptionFromStreamError(e) self.assert_(isinstance(result, error.StreamError)) self.assertEquals('xml-not-well-formed', result.condition)