Skip to content
Permalink
Browse files

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 c6912836e88eea45aef7d515383e549082d37717
Showing with 3 additions and 1 deletion.
  1. +3 −1 googleapiclient/http.py
@@ -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):

0 comments on commit c691283

Please sign in to comment.