Narrow the scope of a try/except

This commit is contained in:
mathieui 2017-10-11 23:41:32 +02:00
parent 9a7c2c2136
commit 38a0e614d4

View file

@ -14,6 +14,7 @@ slix plugin
from xml.etree import cElementTree as ET from xml.etree import cElementTree as ET
from poezio.common import safeJID from poezio.common import safeJID
from slixmpp.exceptions import IqError, IqTimeout
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -144,7 +145,7 @@ def set_user_role(xmpp, jid, nick, reason, role, callback=None):
return iq.send(callback=callback) return iq.send(callback=callback)
try: try:
return iq.send() return iq.send()
except Exception as e: except (IqError, IqTimeout) as e:
return e.iq return e.iq
def set_user_affiliation(xmpp, muc_jid, affiliation, nick=None, jid=None, reason=None, callback=None): def set_user_affiliation(xmpp, muc_jid, affiliation, nick=None, jid=None, reason=None, callback=None):