diff options
author | 2015-11-22 21:45:19 +0000 | |
---|---|---|
committer | 2015-11-22 21:45:19 +0000 | |
commit | e6cd2b064e1095184debc58d8bc4b7d38f228117 (patch) | |
tree | 5370b1e952fa19b7c9441e34c765a487cd2bbaa1 /moonclient | |
parent | e4a6b85f84658233a9af2d83f57a24293b2a6650 (diff) | |
parent | c836fda3fa4bf4250790353ca31b9d600ee0fdd8 (diff) |
Merge "Get errors from Keystone-Moon and throw them from Moonclient"
Diffstat (limited to 'moonclient')
-rw-r--r-- | moonclient/moonclient/shell.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/moonclient/moonclient/shell.py b/moonclient/moonclient/shell.py index 49422a45..5e40bf40 100644 --- a/moonclient/moonclient/shell.py +++ b/moonclient/moonclient/shell.py @@ -150,9 +150,21 @@ class MoonClient(App): content = resp.read() conn.close() try: - return json.loads(content) + content = json.loads(content) + if "error" in content: + try: + raise Exception("Getting an error while requiring {} ({}: {}, {})".format( + url, + content['error']['code'], + content['error']['title'], + content['error']['message'], + )) + except ValueError: + raise Exception("Getting an error while requiring {} ({})".format(url, content)) + return content except ValueError: - return {"content": content} + raise Exception("Getting an error while requiring {} ({})".format(url, content)) + # return {"content": content} def auth_keystone(self, username=None, password=None, host=None, port=None): """Send a new authentication request to Keystone |