'Create new error node object.
Mandatory parameter: name - name of error condition.
Optional parameters: code, typ, text. Used for backwards compartibility with older jabber protocol.'

def __init__(self, name, code=None, typ=None, text=None):

    if ERRORS.has_key(name):
        (cod, type, txt) = ERRORS[name]
        ns = name.split()[0]
    else:
        (cod, ns, type, txt) = ('500', NS_STANZAS, 'cancel', '')
    if typ:
        type = typ
    if code:
        cod = code
    if text:
        txt = text
    Node.__init__(self, 'error', {}, [Node(name)])
    if type:
        self.setAttr('type', type)
    if (not cod):
        self.setName('stream:error')
    if txt:
        self.addChild(node=Node((ns + '    text'), {}, [txt]))
    if cod:
        self.setAttr('code', cod)
