Skip to content

Commit c43e41d

Browse files
committed
add catch if query returns error
1 parent a226f59 commit c43e41d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/github_analyser/licences.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ def get_licence(
4040

4141
response = request_github_graphql({"query": query})
4242
# extract repo id from the first response
43-
repo_id = None
44-
if response:
45-
repo_id = response["data"]["repository"]["id"]
46-
repo_url = response["data"]["repository"]["url"]
43+
if "errors" in response:
44+
print(f"Failed to get licence data for {repo_name}: {response['errors']}")
45+
return pd.Series()
4746

47+
repo_id = response["data"]["repository"]["id"]
48+
repo_url = response["data"]["repository"]["url"]
4849
licence_info = response["data"]["repository"]["licenseInfo"]
4950

5051
if licence_info is None:

0 commit comments

Comments
 (0)