mirror of
https://github.com/element-hq/synapse
synced 2024-08-20 01:30:20 +00:00
More sane handling of group errors and pep8
This commit is contained in:
parent
e3586f7c06
commit
7bb651de6a
1 changed files with 5 additions and 4 deletions
|
@ -20,7 +20,7 @@ from six import iteritems
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.api.errors import (SynapseError, HttpResponseException)
|
from synapse.api.errors import (HttpResponseException, SynapseError)
|
||||||
from synapse.types import get_domain_from_id
|
from synapse.types import get_domain_from_id
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -40,12 +40,13 @@ def _create_rerouter(func_name):
|
||||||
d = getattr(self.transport_client, func_name)(
|
d = getattr(self.transport_client, func_name)(
|
||||||
destination, group_id, *args, **kwargs
|
destination, group_id, *args, **kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
def h(failure):
|
def h(failure):
|
||||||
failure.trap(HttpResponseException)
|
failure.trap(HttpResponseException)
|
||||||
e = failure.value
|
e = failure.value
|
||||||
if e.code >= 400 and e.code < 500:
|
if e.code == 403:
|
||||||
raise SynapseError(e.code, e.msg)
|
raise e.to_synapse_error()
|
||||||
failure.raiseException()
|
return failure
|
||||||
d.addErrback(h)
|
d.addErrback(h)
|
||||||
return d
|
return d
|
||||||
return f
|
return f
|
||||||
|
|
Loading…
Reference in a new issue