'Create and send an error reply.
Typically called when an event handler raises an exception.
The error\'s type and text content are based on the exception
object\'s type and content.
Overrides StanzaBase.exception.
Arguments:
e -- Exception object'

def exception(self, e):

    if isinstance(e, IqError):
        self.reply()
        self['error']['condition'] = 'undefined-condition'
        self['error']['text'] = 'External    error'
        self['error']['type'] = 'cancel'
        log.warning('You    should    catch    IqError    exceptions')
        self.send()
    elif isinstance(e, IqTimeout):
        self.reply()
        self['error']['condition'] = 'remote-server-timeout'
        self['error']['type'] = 'wait'
        log.warning('You    should    catch    IqTimeout    exceptions')
        self.send()
    elif isinstance(e, XMPPError):
        keep_id = self['id']
        self.reply(clear=e.clear)
        self['id'] = keep_id
        self['error']['condition'] = e.condition
        self['error']['text'] = e.text
        self['error']['type'] = e.etype
        if (e.extension is not None):
            extxml = ET.Element(('{%s}%s' % (e.extension_ns, e.extension)), e.extension_args)
            self['error'].append(extxml)
        self.send()
    else:
        keep_id = self['id']
        self.reply()
        self['id'] = keep_id
        self['error']['condition'] = 'undefined-condition'
        self['error']['text'] = 'SleekXMPP    got    into    trouble.'
        self['error']['type'] = 'cancel'
        self.send()
        log.exception('Error    handling    {%s}%s    stanza', self.namespace, self.name)
        self.stream.exception(e)
