Skip to content

Commit f257d0b

Browse files
authored
Merge pull request #39 from SanteeMarcel/patch-1
improve error raising
2 parents bc2943a + e7a4931 commit f257d0b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

utils/crawl_github_files.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ def fetch_contents(path):
173173
if not token:
174174
print(f"Error 404: Repository not found or is private.\n"
175175
f"If this is a private repository, please provide a valid GitHub token via the 'token' argument or set the GITHUB_TOKEN environment variable.")
176+
elif not path and ref == 'main':
177+
print(f"Error 404: Repository not found. Check if the default branch is not 'main'\n"
178+
f"Try adding branch name to the request i.e. python main.py --repo https://github.com/username/repo/tree/master")
176179
else:
177180
print(f"Error 404: Path '{path}' not found in repository or insufficient permissions with the provided token.\n"
178181
f"Please verify the token has access to this repository and the path exists.")
@@ -309,4 +312,4 @@ def fetch_contents(path):
309312
if files:
310313
sample_file = next(iter(files))
311314
print(f"\nSample file: {sample_file}")
312-
print(f"Content preview: {files[sample_file][:200]}...")
315+
print(f"Content preview: {files[sample_file][:200]}...")

0 commit comments

Comments
 (0)