Skip to content

Commit

Permalink
Handle GitHub API rate limit
Browse files Browse the repository at this point in the history
GitHub API has serious rate limit for tokenless queries.

So instead of failing with traceback just print info that GitHub
API rate limit was exceeded.
  • Loading branch information
hrw authored and psss committed Aug 8, 2022
1 parent e1a809d commit 6cf907c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions did/plugins/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ def search(self, query):
try:
data = json.loads(response.text)["items"]
result.extend(data)
except KeyError:
if json.loads(response.text)["message"].startswith(
"API rate limit exceeded"):
raise ReportError(
"GitHub API rate limit exceeded. "
"Consider creating an access token.")
except requests.exceptions.JSONDecodeError as error:
log.debug(error)
raise ReportError(f"GitHub JSON failed: {response.text}.")
Expand Down

0 comments on commit 6cf907c

Please sign in to comment.