diff options
author | George Peristerakis <gperiste@redhat.com> | 2015-12-08 16:02:29 -0500 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-02-29 15:57:48 +0900 |
commit | 8a0e736a2bad1e4ac0dfcd63892034558a1862f6 (patch) | |
tree | 4c48d50c699bf1da816ac68793b02dd7a7656a0c | |
parent | 6ea650e2c3c5cdc7ce80249449fe7ccaaaf35ace (diff) | |
download | pygerrit-8a0e736a2bad1e4ac0dfcd63892034558a1862f6.tar.gz |
Raise exception if the json content is invalid
If the json loads function raises, the return content is invalid.
The function should log the error and raise the exception.
Closes #32
Change-Id: I053b0169c8da47f2a4812cc30783f8a4776f9c2b
-rw-r--r-- | pygerrit/rest/__init__.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/pygerrit/rest/__init__.py b/pygerrit/rest/__init__.py index 49cc434..e578e96 100644 --- a/pygerrit/rest/__init__.py +++ b/pygerrit/rest/__init__.py @@ -41,7 +41,7 @@ def _decode_response(response): requests.HTTPError if the response contains an HTTP error status code. """ - content = response.content + content = response.content.strip() logging.debug(content[:512]) response.raise_for_status() if content.startswith(GERRIT_MAGIC_JSON_PREFIX): @@ -49,7 +49,8 @@ def _decode_response(response): try: return json.loads(content) except ValueError: - return content.strip() + logging.error('Invalid json content: %s' % content) + raise class GerritRestAPI(object): |