diff idavoll/idavoll.py @ 159:6fe78048baf9

Rework error handling, depend on Twisted Words 0.4.0. Twisted Words 0.4.0 introduced support for stanza error handling, much better than the custom error handling in Idavoll. Also, all protocol-level errors were examined and brought up to date with version 1.8 of JEP-0060. As a result of the error examination, the retrieval of default configuration options using <default/> is now supported properly.
author Ralph Meijer <ralphm@ik.nu>
date Wed, 06 Sep 2006 12:38:47 +0000
parents 5191ba7c4df8
children 1701c0e2c707
line wrap: on
line diff
--- a/idavoll/idavoll.py	Thu Jun 18 11:52:01 2009 +0000
+++ b/idavoll/idavoll.py	Wed Sep 06 12:38:47 2006 +0000
@@ -1,12 +1,11 @@
 # Copyright (c) 2003-2006 Ralph Meijer
 # See LICENSE for details.
 
-from twisted.words.protocols.jabber import component
+from twisted.words.protocols.jabber import component, error
 from twisted.application import service
 from twisted.internet import defer
 import backend
 import pubsub
-import xmpp_error
 import disco
 
 import sys
@@ -69,7 +68,7 @@
             info.extend(i[1])
 
         if node and not info:
-            return xmpp_error.error_from_iq(iq, 'item-not-found')
+            return error.StanzaError('item-not-found').toResponse(iq)
         else:
             iq.swapAttributeValues("to", "from")
             iq["type"] = "result"
@@ -85,7 +84,7 @@
     def _error(self, result, iq):
         print "Got error on index %d:" % result.value[1]
         result.value[0].printBriefTraceback()
-        return xmpp_error.error_from_iq(iq, 'internal-server-error')
+        return error.StanzaError('internal-server-error').toResponse(iq)
 
     def onDiscoItems(self, iq):
         dl = []
@@ -118,7 +117,7 @@
         if iq.handled == True:
             return
 
-        self.send(xmpp_error.error_from_iq(iq, 'service-unavailable'))
+        self.send(error.StanzaError('service-unavailable').toResponse(iq))
 
 class LogService(component.Service):