plugin XEP-0060: raise an NotFound exception instead of StanzaError in subscribe:
`exceptions.NotFound` is now raised in stead of `item-not-found` `StanzaError` for consistency with `getItems` and because it's easier to catch (condition has to be checked when `StanzaError` is received). rel 372
This commit is contained in:
parent
1e4fc213f6
commit
2502e5062a
1 changed files with 10 additions and 4 deletions
|
|
@ -1207,10 +1207,16 @@ class XEP_0060(object):
|
|||
)
|
||||
if not cont:
|
||||
return trigger_sub
|
||||
subscription = await client.pubsub_client.subscribe(
|
||||
service, nodeIdentifier, sub_jid or client.jid.userhostJID(), options=options,
|
||||
sender=client.jid.userhostJID()
|
||||
)
|
||||
try:
|
||||
subscription = await client.pubsub_client.subscribe(
|
||||
service, nodeIdentifier, sub_jid or client.jid.userhostJID(),
|
||||
options=options, sender=client.jid.userhostJID()
|
||||
)
|
||||
except error.StanzaError as e:
|
||||
if e.condition == 'item-not-found':
|
||||
raise exceptions.NotFound(e.text or e.condition)
|
||||
else:
|
||||
raise e
|
||||
return subscription
|
||||
|
||||
def _unsubscribe(self, service, nodeIdentifier, profile_key=C.PROF_KEY_NONE):
|
||||
|
|
|
|||
Loading…
Reference in a new issue