Skip to content

Commit

Permalink
Changes wrong error message when trying to set not existed GitHub use…
Browse files Browse the repository at this point in the history
…r. (#144)
  • Loading branch information
Artanias authored Dec 11, 2022
1 parent 0825c33 commit 878e9fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
UTIL_VERSION := 0.2.7
UTIL_VERSION := 0.2.8
UTIL_NAME := codeplag
PWD := $(shell pwd)

Expand Down
19 changes: 8 additions & 11 deletions src/webparsers/github_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,32 @@ def send_get_request(
# Recommended
'accept': 'application/vnd.github.v3+json'
}
url = address + api_url
if self.__access_token != '':
headers.update({
'Authorization': 'token ' + self.__access_token,
})

# Check Ethernet connection and requests limit
try:
response = requests.get(address + api_url, headers=headers,
params=params)
response = requests.get(url, headers=headers, params=params)
except requests.exceptions.ConnectionError as err:
self.logger.error(
"Connection error. Please check the Internet connection."
)
self.logger.debug(str(err))
sys.exit(1)

if response.status_code == 403:
if 'message' in response.json():
self.logger.error(
"GitHub " + response.json()['message']
)
sys.exit(1)

raise KeyError
if response.status_code in [400, 403, 404]:
self.logger.error(
f"GitHub error: '{response.json()['message']}' for url '{url}'."
)
sys.exit(1)

try:
response.raise_for_status()
except requests.exceptions.HTTPError as err:
self.logger.error("The access token is bad")
self.logger.error("The access token is bad.")
self.logger.debug(str(err))
sys.exit(1)

Expand Down

0 comments on commit 878e9fd

Please sign in to comment.