diff --git a/gitmon/api.py b/gitmon/api.py index 79b5e10..0cb5f00 100644 --- a/gitmon/api.py +++ b/gitmon/api.py @@ -72,9 +72,12 @@ class GitHubApi: headers (dict): The response headers from the GitHub API. """ - self.rate_reset = datetime.fromtimestamp(int(headers['x-ratelimit-reset'])) - self.rate_remaining = int(headers['x-ratelimit-remaining']) - logger.info(f'{self.rate_remaining} calls remaining until {self.rate_reset} ({self.rate_reset - datetime.now()})') + try: + self.rate_reset = datetime.fromtimestamp(int(headers['x-ratelimit-reset'])) + self.rate_remaining = int(headers['x-ratelimit-remaining']) + logger.info(f'{self.rate_remaining} calls remaining until {self.rate_reset} ({self.rate_reset - datetime.now()})') + except KeyError as e: + logger.warning(f'Could not parse headers: {str(e)}') def get_events(self, page=None): """Fetch GitHub events.