core (memory): catch exceptions.UnknownEntityError in getMainResource

This commit is contained in:
Goffi 2015-11-26 17:00:18 +01:00
commit 939b6ba80b

View file

@ -565,6 +565,7 @@ class Memory(object):
return (list[unicode]): list of resources
@raise exceptions.UnknownEntityError: if entity is not in cache
@raise ValueError: entity_jid has a resource
"""
if entity_jid.resource:
raise ValueError("getAllResources must be used with a bare jid (got {})".format(entity_jid))
@ -618,7 +619,11 @@ class Memory(object):
return None # MUC rooms have no main resource
except KeyError: # plugin not found
pass
resources = self.getAllResources(entity_jid, profile_key)
try:
resources = self.getAllResources(entity_jid, profile_key)
except exceptions.UnknownEntityError:
log.warning(u"Entity is not in cache, we can't find any resource")
return None
priority_resources = []
for resource in resources:
full_jid = copy.copy(entity_jid)