Merge pull request #327 from spiritualized/master

This commit is contained in:
Hugo van Kemenade 2020-05-08 12:24:12 +03:00 committed by GitHub
commit 2aaa594388
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -932,7 +932,15 @@ class _Request:
raise NetworkError(self.network, e) raise NetworkError(self.network, e)
try: try:
response_text = _unicode(conn.getresponse().read()) response = conn.getresponse()
if response.status in [500, 502, 503, 504]:
raise WSError(
self.network,
response.status,
"Connection to the API failed with HTTP code "
+ str(response.status),
)
response_text = _unicode(response.read())
except Exception as e: except Exception as e:
raise MalformedResponseError(self.network, e) raise MalformedResponseError(self.network, e)