Merge "Improve error message parsing"

This commit is contained in:
Jenkins 2017-02-24 03:39:48 +00:00 committed by Gerrit Code Review
commit c2c4bf3e8a

View File

@ -44,11 +44,17 @@ def _extract_error_json(body):
if 'error_message' in body_json:
raw_msg = body_json['error_message']
error_json = json.loads(raw_msg)
elif 'error' in body_json:
error_body = body_json['error']
error_json = {'faultstring': error_body['title'],
'debuginfo': error_body['message']}
else:
error_body = body_json['errors'][0]
raw_msg = error_body['title']
error_json = {'faultstring': error_body['title'],
'debuginfo': error_body['detail']}
error_json = {'faultstring': error_body['title']}
if 'detail' in error_body:
error_json['debuginfo'] = error_body['detail']
elif 'description' in error_body:
error_json['debuginfo'] = error_body['description']
except ValueError:
return {}