From f41aed19af309767cf3103509e87648a3c250497 Mon Sep 17 00:00:00 2001 From: Goffi Date: Tue, 25 Aug 2015 16:52:18 +0200 Subject: [PATCH] core (disco): use of failure.Failure when raising FeatureNotFound to avoid a jump in debugger in debug mode --- src/memory/disco.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/memory/disco.py b/src/memory/disco.py index 533c3463..31764cf9 100755 --- a/src/memory/disco.py +++ b/src/memory/disco.py @@ -25,6 +25,7 @@ from twisted.words.protocols.jabber import jid from twisted.words.protocols.jabber.error import StanzaError from twisted.internet import defer from twisted.internet import reactor +from twisted.python import failure from sat.core.constants import Const as C from wokkel import disco from base64 import b64encode @@ -86,7 +87,7 @@ class Discovery(object): """ disco_infos = yield self.getInfos(jid_, profile_key) if not feature in disco_infos.features: - raise exceptions.FeatureNotFound + raise failure.Failure(exceptions.FeatureNotFound) @defer.inlineCallbacks def checkFeatures(self, features, jid_=None, identity=None, profile_key=C.PROF_KEY_NONE): @@ -101,10 +102,10 @@ class Discovery(object): """ disco_infos = yield self.getInfos(jid_, profile_key) if not set(features).issubset(disco_infos.features): - raise exceptions.FeatureNotFound + raise failure.Failure(exceptions.FeatureNotFound()) if identity is not None and identity not in disco_infos.identities: - raise exceptions.FeatureNotFound + raise failure.Failure(exceptions.FeatureNotFound()) def getInfos(self, jid_=None, profile_key=C.PROF_KEY_NONE): """get disco infos from jid_, filling capability hash if needed @@ -158,10 +159,10 @@ class Discovery(object): defer.returnValue(items) - def _infosEb(self, failure, entity_jid): - failure.trap(StanzaError) + def _infosEb(self, failure_, entity_jid): + failure_.trap(StanzaError) log.warning(_(u"Error while requesting [%(jid)s]: %(error)s") % {'jid': entity_jid.full(), - 'error': failure.getErrorMessage()}) + 'error': failure_.getErrorMessage()}) def findServiceEntities(self, category, type_, jid_=None, profile_key=C.PROF_KEY_NONE): """Return all available items of an entity which correspond to (category, type_)