From 6eb97a2da73e1d71a53d3039474de34b0408f478 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Wed, 5 Apr 2023 14:15:16 -0700 Subject: [PATCH] Include headers in GitHubError, refs #79 --- github_to_sqlite/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/github_to_sqlite/utils.py b/github_to_sqlite/utils.py index 9e728fc..f934d76 100644 --- a/github_to_sqlite/utils.py +++ b/github_to_sqlite/utils.py @@ -74,16 +74,17 @@ class GitHubError(Exception): - def __init__(self, message, status_code): + def __init__(self, message, status_code, headers=None): self.message = message self.status_code = status_code + self.headers = headers @classmethod def from_response(cls, response): message = response.json()["message"] if "git repository is empty" in message.lower(): cls = GitHubRepositoryEmpty - return cls(message, response.status_code) + return cls(message, response.status_code, response.headers) class GitHubRepositoryEmpty(GitHubError):