diff options
author | David Baker <dave@matrix.org> | 2017-04-26 10:07:01 +0100 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2017-04-26 10:07:01 +0100 |
commit | c3662760566a7cdf48442d399fbffb9163590dc5 (patch) | |
tree | 02f3fe9bdd9d925c5e6470c27be8729efc272a14 /synapse/http | |
parent | Use CodeMessageException subclass instead (diff) | |
download | synapse-c3662760566a7cdf48442d399fbffb9163590dc5.tar.xz |
Fix get_json
Diffstat (limited to 'synapse/http')
-rw-r--r-- | synapse/http/client.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/synapse/http/client.py b/synapse/http/client.py index 57a49b2827..6e0ddfa0f6 100644 --- a/synapse/http/client.py +++ b/synapse/http/client.py @@ -169,12 +169,11 @@ class SimpleHttpClient(object): On a non-2xx HTTP response. The response body will be used as the error message. """ - body = yield self.get_raw(uri, args) - - if 200 <= response.code < 300: + try: + body = yield self.get_raw(uri, args) defer.returnValue(json.loads(body)) - else: - raise self._exceptionFromFailedRequest(response, body) + except CodeMessageException as e: + raise self._exceptionFromFailedRequest(e.code, e.msg) @defer.inlineCallbacks def put_json(self, uri, json_body, args={}): |