Handle HttpResponseException more safely for federated groups

This commit is contained in:
Travis Ralston 2018-09-26 13:26:45 -06:00
parent 219606a6ed
commit b4c3bc1734
1 changed files with 11 additions and 2 deletions

View File

@ -20,7 +20,7 @@ from six import iteritems
from twisted.internet import defer
from synapse.api.errors import SynapseError
from synapse.api.errors import (SynapseError, HttpResponseException)
from synapse.types import get_domain_from_id
logger = logging.getLogger(__name__)
@ -37,9 +37,18 @@ def _create_rerouter(func_name):
)
else:
destination = get_domain_from_id(group_id)
return getattr(self.transport_client, func_name)(
logger.info("Triggering call")
d = getattr(self.transport_client, func_name)(
destination, group_id, *args, **kwargs
)
def h(failure):
failure.trap(HttpResponseException)
e = failure.value
if e.code >= 400 and e.code < 500:
raise SynapseError(e.code, e.msg)
failure.raiseException()
d.addErrback(h)
return d
return f