summaryrefslogtreecommitdiff
path: root/heatclient/exc.py
diff options
context:
space:
mode:
authorSteve Baker <sbaker@redhat.com>2012-12-11 13:48:55 +1300
committerSteve Baker <sbaker@redhat.com>2012-12-11 13:48:55 +1300
commitc7130de0a979c8adb32fd52efd41ae05456d9d55 (patch)
treeb3cb26829820204b501ad0ab647181b61085464b /heatclient/exc.py
parente1ce4162e48c9de2e1b4edee2d66467e6c3793e6 (diff)
downloadpython-heatclient-c7130de0a979c8adb32fd52efd41ae05456d9d55.tar.gz
Display a better error message on HTTP exception
Instead of just getting the HTTP code, the message from the actual exception is printed to the console Change-Id: I43265e1e01e3e972e444778b3058637c0e1fd441
Diffstat (limited to 'heatclient/exc.py')
-rw-r--r--heatclient/exc.py17
1 files changed, 4 insertions, 13 deletions
diff --git a/heatclient/exc.py b/heatclient/exc.py
index d768fbf..7d32bc1 100644
--- a/heatclient/exc.py
+++ b/heatclient/exc.py
@@ -34,20 +34,10 @@ class CommunicationError(BaseException):
"""Unable to communicate with server."""
-class ClientException(Exception):
- """DEPRECATED"""
-
-
-class HTTPException(ClientException):
+class HTTPException(BaseException):
"""Base exception for all HTTP-derived exceptions"""
code = 'N/A'
- def __init__(self, details=None):
- self.details = details
-
- def __str__(self):
- return "%s (HTTP %s)" % (self.__class__.__name__, self.code)
-
class HTTPMultipleChoices(HTTPException):
code = 300
@@ -147,10 +137,11 @@ for obj_name in dir(sys.modules[__name__]):
_code_map[obj.code] = obj
-def from_response(response):
+def from_response(response, body_iter):
"""Return an instance of an HTTPException based on httplib response."""
cls = _code_map.get(response.status, HTTPException)
- return cls()
+ body_str = ''.join([chunk for chunk in body_iter])
+ return cls(body_str)
class NoTokenLookupException(Exception):