tools (sat_defer), plugin XEP-0060: added a function "stanza2NotFound" to convert item-not-found StanzaError to exceptions.NotFound in an errback
This commit is contained in:
parent
d85f1b364f
commit
1ccb54e571
2 changed files with 10 additions and 0 deletions
|
|
@ -611,6 +611,7 @@ class XEP_0060(object):
|
|||
)
|
||||
# we have no MAM data here, so we add None
|
||||
d.addCallback(lambda data: data + (None,))
|
||||
d.addErrback(sat_defer.stanza2NotFound)
|
||||
d.addTimeout(TIMEOUT, reactor)
|
||||
else:
|
||||
# if mam is requested, we have to do a totally different query
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ from sat.core import exceptions
|
|||
from twisted.internet import defer
|
||||
from twisted.internet import error as internet_error
|
||||
from twisted.internet import reactor
|
||||
from twisted.words.protocols.jabber import error as jabber_error
|
||||
from twisted.python import failure
|
||||
from sat.core.constants import Const as C
|
||||
from sat.memory import memory
|
||||
|
|
@ -34,6 +35,14 @@ KEY_DEFERREDS = "deferreds"
|
|||
KEY_NEXT = "next_defer"
|
||||
|
||||
|
||||
def stanza2NotFound(failure_):
|
||||
"""Convert item-not-found StanzaError to exceptions.NotFound"""
|
||||
failure_.trap(jabber_error.StanzaError)
|
||||
if failure_.value.condition == u'item-not-found':
|
||||
raise exceptions.NotFound(failure_.value.text or failure_.value.condition)
|
||||
return failure_
|
||||
|
||||
|
||||
class DelayedDeferred(object):
|
||||
"""A Deferred-like which is launched after a delay"""
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue