Skip to content

Commit 74dc0d0

Browse files
committed
mitigate KeyError for github 'X-RateLimit-Remaining'; see issue 59
1 parent 6bdf304 commit 74dc0d0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

adabot/github_requests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ def _fix_kwargs(kwargs):
5858

5959
def get(url, **kwargs):
6060
response = requests.get(_fix_url(url), **_fix_kwargs(kwargs))
61-
remaining = int(response.headers["X-RateLimit-Remaining"])
62-
if remaining % 100 == 0:
63-
print(remaining, "requests remaining this hour")
61+
if "X-RateLimit-Remaining" in response.headers:
62+
remaining = int(response.headers["X-RateLimit-Remaining"])
63+
if remaining % 100 == 0:
64+
print(remaining, "requests remaining this hour")
6465
return response
6566

6667
def post(url, **kwargs):

0 commit comments

Comments
 (0)