Skip to content

Commit

Permalink
fix logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Karina5005 committed Aug 21, 2023
1 parent 7ff1840 commit f84b3ee
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions backup_github/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,26 @@ def __init__(self, message=None):
def raise_by_status(self, response):
if response.status_code == 403:
logging.warning("Status is 403 - Rate limit exceeded exception")
raise self.RateLimitExceededException(json.loads(response.content))
raise self.RateLimitExceededException(
json.loads(response.content) if response.content else None
)
elif response.status_code == 404:
logging.warning(
f"Status is {response.status_code} - Client error: Not found"
)
raise self.ClientError(json.loads(response.content))
raise self.ClientError(
json.loads(response.content) if response.content else None
)
elif 400 <= response.status_code < 500:
logging.warning(f"Status is {response.status_code} - Client error")
raise self.ClientError(json.loads(response.content))
raise self.ClientError(
json.loads(response.content) if response.content else None
)
elif 500 <= response.status_code < 600:
logging.warning(f"Status is {response.status_code} - Server error")
raise self.ServerError(json.loads(response.content))
raise self.ServerError(
json.loads(response.content) if response.content else None
)

def retry(func):
def ret(self, *args, **kwargs):
Expand Down

0 comments on commit f84b3ee

Please sign in to comment.