Skip to content

Commit

Permalink
Include headers in GitHubError, refs #79
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Apr 5, 2023
1 parent 2e84e26 commit 6eb97a2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions github_to_sqlite/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 6eb97a2

Please sign in to comment.