Fix attribute error accessing response.text
The response object *should* be a requests.Response object, which *should* have a .text property. However, there are situations where this is not the case, and in those cases we now won't produce an AttributeError.
This commit is contained in:
parent
54bb506e10
commit
8377dc63c0
@ -94,8 +94,9 @@ class FlaskInternalApi(pillarsdk.Api):
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
exception = exceptions.exception_for_status(response.status_code)
|
exception = exceptions.exception_for_status(response.status_code)
|
||||||
|
text = getattr(response, 'text', '')
|
||||||
if exception:
|
if exception:
|
||||||
raise exception(response, response.text)
|
raise exception(response, text)
|
||||||
|
|
||||||
raise exceptions.ConnectionError(response, response.text,
|
raise exceptions.ConnectionError(response, text,
|
||||||
"Unknown response code: %s" % response.status_code)
|
"Unknown response code: %s" % response.status_code)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user