Merge "Handle strings as response error_message"

This commit is contained in:
Zuul 2018-05-22 12:55:03 +00:00 committed by Gerrit Code Review
commit 1f01925dd3
1 changed files with 5 additions and 2 deletions

View File

@ -165,14 +165,17 @@ def from_response(response, url, method=None):
if "retry-after" in response.headers:
kwargs['retry_after'] = response.headers.get('retry-after')
if content_type == "application/json":
try:
body = response.json()
except ValueError:
pass
else:
desc = body.get('error_message', {}).get('faultstring')
error_message = body.get('error_message', {})
try:
desc = error_message.get('faultstring')
except AttributeError:
desc = error_message
for enhanced_cls in enhanced_classes:
if enhanced_cls.match.match(desc):
cls = enhanced_cls