Go to the latest version of this document.

# ``twisted`.`words`.`protocols`.`jabber`.`error`.`StanzaError``

exception documentation

`class StanzaError(BaseError): (source)`

Constructor: `StanzaError(condition, type, text, textLang, appCondition)`

View In Hierarchy

Stanza Error exception.

Refer to RFC 3920, section 9.3, for the allowed values for `condition` and `type`.

Method | `__init__` | Undocumented
Method | `getElement` | Get XML representation from self.
Method | `toResponse` | Construct error response stanza.
Instance Variable | `children` | Undocumented
Instance Variable | `code` | A numeric identifier for the error condition for backwards compatibility with pre-XMPP Jabber implementations.
Instance Variable | `iq` | Undocumented
Instance Variable | `type` | The stanza error type. Gives a suggestion to the recipient of the error on how to proceed.

Inherited from `BaseError`:

Method | `__str__` | Undocumented
Class Variable | `namespace` | The namespace of the `error` element generated by `getElement`.
Instance Variable | `appCondition` | Application specific condition element, supplementing the error condition in `condition`.
Instance Variable | `condition` | The error condition. The valid values are defined by subclasses of `BaseError`.
Instance Variable | `text` | Optional text message to supplement the condition or application specific condition.
Instance Variable | `textLang` | Identifier of the language used for the message in `text`. Values are as described in RFC 3066.

def __init__(self, condition, type=None, text=None, textLang=None, appCondition=None): (source)
overrides `twisted.words.protocols.jabber.error.BaseError.__init__`

Undocumented

def getElement(self): (source)
overrides `twisted.words.protocols.jabber.error.BaseError.getElement`

Get XML representation from self.

Overrides the base `BaseError.getElement` to make sure the returned element has a `type` attribute and optionally a legacy `code` attribute.

Returns
`domish.Element` | Undocumented

def toResponse(self, stanza): (source)

Construct error response stanza.

The `stanza` is transformed into an error response stanza by swapping the `to` and `from` addresses and inserting an error element.

Parameters
stanza:`domish.Element` | the stanza to respond to

Note
This creates a shallow copy of the list of child elements of the stanza. The child elements themselves are not copied themselves, and references to their parent element will still point to the original stanza element. The serialization of an element does not use the reference to its parent, so the typical use case of immediately sending out the constructed error response is not affected.

children: `list` = (source)

Undocumented

code = (source)

A numeric identifier for the error condition for backwards compatibility with pre-XMPP Jabber implementations.

iq = (source)

Undocumented

type: `str` = (source)

The stanza error type. Gives a suggestion to the recipient of the error on how to proceed.