diff --git a/gitblame.py b/gitblame.py index a97863f..bd7b1c9 100644 --- a/gitblame.py +++ b/gitblame.py @@ -106,17 +106,14 @@ def blame_file(self, file: str) -> dict | None: time.sleep(wait_time) continue response.raise_for_status() - try: - data = response.json()["data"] - except KeyError: - logging.error("%s: %s: %s", file, response.text, response.headers) - return None - return data["repositoryOwner"]["repository"]["object"]["blame"][ - "ranges" - ] + data = response.json()["data"] except RequestException as exc: logging.error("%s: %s", file, exc) return None + except KeyError: + logging.error("%s: %s: %s", file, response.text, response.headers) + return None + return data["repositoryOwner"]["repository"]["object"]["blame"]["ranges"] return None def blame_line(self, file: str, line: int) -> tuple[str, str, str, datetime]: