Skip to content

Commit

Permalink
handle error on service not enabled - closes #1116
Browse files Browse the repository at this point in the history
  • Loading branch information
kapilt committed Dec 1, 2020
1 parent 334b6e6 commit 8f5b998
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 8f5b998

Please sign in to comment.