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:
Goffi 2022-09-21 22:32:36 +02:00
commit 2502e5062a

View file

@ -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):