Skip to content

Commit

Permalink
Merge pull request #7 from diggyk/master
Browse files Browse the repository at this point in the history
Do a better job handling a bad response in the client
  • Loading branch information
rra committed Jun 16, 2015
2 parents 8b2b5ac + 1f3f345 commit 4aa9fda
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
23 changes: 15 additions & 8 deletions bin/hermes
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ def request_get(path):
response = requests.get(settings.hermes_server + path)

if response.status_code != requests.codes.ok:
logging.debug(response.json())
raise HermesException(
"Error: {}".format(response.json()["error"]["message"])
)
try:
data = response.json()["error"]["message"]
except Exception:
data = "Received invalid response: {}".format(response)

raise HermesException(
"Error: {}".format(data)
)

return response

Expand All @@ -57,10 +61,13 @@ def request_post(path, json):
response = requests.post(settings.hermes_server + path, json=json)

if response.status_code != requests.codes.created:
logging.debug(response.json())
raise HermesException(
"Error: {}".format(response.json()["error"]["message"])
)
try:
data = response.json()["error"]["message"]
except Exception:
data = "Received invalid response: {}".format(response)
raise HermesException(
"Error: {}".format(data)
)

return response

Expand Down
2 changes: 1 addition & 1 deletion hermes/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.15"
__version__ = "0.1.16"

0 comments on commit 4aa9fda

Please sign in to comment.