Refactor code for turning HttpResponseException into SynapseError

This commit replaces SynapseError.from_http_response_exception with
HttpResponseException.to_synapse_error.

The new method actually returns a ProxiedRequestError, which allows us to pass
through additional metadata from the API call.
This commit is contained in:
Richard van der Hoff 2018-08-01 14:58:16 +01:00
parent fa7dc889f1
commit 018d75a148
3 changed files with 56 additions and 34 deletions

View file

@ -506,7 +506,7 @@ class FederationClient(FederationBase):
)
except HttpResponseException as e:
if not 500 <= e.code < 600:
raise SynapseError.from_http_response_exception(e)
raise e.to_synapse_error()
else:
logger.warn(
"Failed to %s via %s: %i %s",
@ -682,7 +682,7 @@ class FederationClient(FederationBase):
)
except HttpResponseException as e:
if e.code == 403:
raise SynapseError.from_http_response_exception(e)
raise e.to_synapse_error()
raise
pdu_dict = content["event"]