FIX: Added Error Handling

This commit is contained in:
Anmol
2020-07-21 13:11:20 +05:30
parent 1669e1805d
commit 265addd251

13
main.py
View File

@@ -155,6 +155,13 @@ def generate_commit_list():
def get_stats(): def get_stats():
'''Gets API data and returns markdown progress''' '''Gets API data and returns markdown progress'''
stats = '' stats = ''
if showCommit.lower() in ['true', '1', 't', 'y', 'yes']:
try:
stats = stats + generate_commit_list() + '\n\n'
except Exception as ex:
print("GitHub Personal access token not configured properly or invalid" + str(ex))
try: try:
request = requests.get( request = requests.get(
f"https://wakatime.com/api/v1/users/current/stats/last_7_days?api_key={waka_key}") f"https://wakatime.com/api/v1/users/current/stats/last_7_days?api_key={waka_key}")
@@ -189,12 +196,6 @@ def get_stats():
except Exception as e: except Exception as e:
print("Waka Time Api Key Not Configured" + str(e)) print("Waka Time Api Key Not Configured" + str(e))
if showCommit.lower() in ['true', '1', 't', 'y', 'yes']:
try:
stats = stats + generate_commit_list() + '\n\n'
except Exception as ex:
print("GitHub Personal access token not configured properly or invalid" + str(ex))
return stats return stats