summaryrefslogtreecommitdiff
path: root/sleekxmpp/stanza/iq.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-05-31 12:48:43 -0700
committerLance Stout <lancestout@gmail.com>2011-06-01 15:17:22 -0700
commit8aa4396e4490a964e3e1b1a5e6f555e97c16fd3d (patch)
treeed58dc66611c99710a404fe5795f9f3d4364f777 /sleekxmpp/stanza/iq.py
parent14693233504383d4df0ed092c870d5d7baea6538 (diff)
downloadslixmpp-8aa4396e4490a964e3e1b1a5e6f555e97c16fd3d.tar.gz
slixmpp-8aa4396e4490a964e3e1b1a5e6f555e97c16fd3d.tar.bz2
slixmpp-8aa4396e4490a964e3e1b1a5e6f555e97c16fd3d.tar.xz
slixmpp-8aa4396e4490a964e3e1b1a5e6f555e97c16fd3d.zip
Begin experimental use of exceptions.
Provides IqTimeout and IqError which are raised when an Iq response does not arrive in time, or it arrives with type='error'.
Diffstat (limited to 'sleekxmpp/stanza/iq.py')
-rw-r--r--sleekxmpp/stanza/iq.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/sleekxmpp/stanza/iq.py b/sleekxmpp/stanza/iq.py
index 4a12a87e..71419bc4 100644
--- a/sleekxmpp/stanza/iq.py
+++ b/sleekxmpp/stanza/iq.py
@@ -11,6 +11,7 @@ from sleekxmpp.stanza.rootstanza import RootStanza
from sleekxmpp.xmlstream import StanzaBase, ET
from sleekxmpp.xmlstream.handler import Waiter, Callback
from sleekxmpp.xmlstream.matcher import MatcherId
+from sleekxmpp.exceptions import IqTimeout, IqError
class Iq(RootStanza):
@@ -197,7 +198,12 @@ class Iq(RootStanza):
waitfor = Waiter('IqWait_%s' % self['id'], MatcherId(self['id']))
self.stream.register_handler(waitfor)
StanzaBase.send(self, now=now)
- return waitfor.wait(timeout)
+ result = waitfor.wait(timeout)
+ if not result:
+ raise IqTimeout()
+ if result['type'] == 'error':
+ raise IqError(result)
+ return result
else:
return StanzaBase.send(self, now=now)