Return response as error if not valid json object
If the response returned by Mistral do not contain a valid json an exception is thrown by the client due to invalid json format. If there's a ValueError exception and it's an error code try to return the response text instead. (Ex: Authorization Failed ) This may be a temporary fix if the BE is able to return the json error msg returned by keystone. Change-Id: I540f3aaa35fb15adc04bf0a33e46af8ac614c814 Closes-Bug: #1316298
This commit is contained in:
@@ -133,8 +133,11 @@ class ResourceManager(object):
|
|||||||
return self.resource_class.resource_name + 's'
|
return self.resource_class.resource_name + 's'
|
||||||
|
|
||||||
def _raise_api_exception(self, resp):
|
def _raise_api_exception(self, resp):
|
||||||
error_data = get_json(resp)
|
try:
|
||||||
raise APIException(error_data["faultstring"])
|
error_data = get_json(resp).get("faultstring")
|
||||||
|
except ValueError:
|
||||||
|
error_data = resp.content
|
||||||
|
raise APIException(error_data)
|
||||||
|
|
||||||
|
|
||||||
def get_json(response):
|
def get_json(response):
|
||||||
|
Reference in New Issue
Block a user