Handling exception on 504 Error

When load balancer/proxy return 504, client raises ValueError.
This happen when response is not a JSON object.
ValueError Exception is needed to be handled.

Change-Id: Iaa8d577f99137327f6e7ad9c7c6abc350f4cc938
Closes-Bug: #1358889
This commit is contained in:
Shaifali Agrawal 2014-11-24 08:42:27 -08:00
parent 2acbced0ea
commit ff13b7a6ac
1 changed files with 7 additions and 3 deletions

View File

@ -42,6 +42,10 @@ class Response(object):
@property
def deserialized_content(self):
if not self._deserialized and self.content:
self._deserialized = json.loads(self.content)
return self._deserialized
try:
if not self._deserialized and self.content:
self._deserialized = json.loads(self.content)
return self._deserialized
except ValueError as ex:
print("Response is not a JSON object.", ex)
return None