improve error raising

This commit is contained in:
Marcel Santee
2025-04-22 14:15:23 -03:00
committed by GitHub
parent bc2943a994
commit e7a4931d37
+4 -1
View File
@@ -173,6 +173,9 @@ def crawl_github_files(
if not token: if not token:
print(f"Error 404: Repository not found or is private.\n" print(f"Error 404: Repository not found or is private.\n"
f"If this is a private repository, please provide a valid GitHub token via the 'token' argument or set the GITHUB_TOKEN environment variable.") f"If this is a private repository, please provide a valid GitHub token via the 'token' argument or set the GITHUB_TOKEN environment variable.")
elif not path and ref == 'main':
print(f"Error 404: Repository not found. Check if the default branch is not 'main'\n"
f"Try adding branch name to the request i.e. python main.py --repo https://github.com/username/repo/tree/master")
else: else:
print(f"Error 404: Path '{path}' not found in repository or insufficient permissions with the provided token.\n" print(f"Error 404: Path '{path}' not found in repository or insufficient permissions with the provided token.\n"
f"Please verify the token has access to this repository and the path exists.") f"Please verify the token has access to this repository and the path exists.")
@@ -309,4 +312,4 @@ if __name__ == "__main__":
if files: if files:
sample_file = next(iter(files)) sample_file = next(iter(files))
print(f"\nSample file: {sample_file}") print(f"\nSample file: {sample_file}")
print(f"Content preview: {files[sample_file][:200]}...") print(f"Content preview: {files[sample_file][:200]}...")