Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: handle error on service not enabled (#1117)
Fixes #1116 馃

Don't throw invalid JSON messages for valid JSON.
  • Loading branch information
kapilt committed Dec 2, 2020
1 parent 334b6e6 commit c691283
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion googleapiclient/http.py
Expand Up @@ -116,7 +116,9 @@ def _should_retry_response(resp_status, content):
try:
data = json.loads(content.decode("utf-8"))
if isinstance(data, dict):
reason = data["error"]["errors"][0]["reason"]
reason = data["error"].get("status")
if reason is None:
reason = data["error"]["errors"][0]["reason"]
else:
reason = data[0]["error"]["errors"]["reason"]
except (UnicodeDecodeError, ValueError, KeyError):
Expand Down

0 comments on commit c691283

Please sign in to comment.