From ad96cac750608fa5caa950fdb69e912366ae6edc Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Sun, 23 Mar 2025 11:15:44 +0100 Subject: [PATCH] covered newly discovered edge case --- handlers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/handlers.py b/handlers.py index 25a11cc..2b94b28 100644 --- a/handlers.py +++ b/handlers.py @@ -135,6 +135,9 @@ class BuildHandler(ABC): if not filepath.endswith('.java'): raise NotJavaFileError(f"File '{filepath}' does not end with .java") + if not os.path.exists(os.path.join(self.path, filepath)): + raise FileNotFoundInRepoError(f"File '{filepath}' not found in repo") + with open(os.path.join(self.path, filepath)) as f: try: parsed_tree = javalang.parse.parse(f.read()) @@ -360,6 +363,9 @@ class NotJavaFileError(HandlerException): class NoPackageFoundError(HandlerException): reason_for_failure = "Java file did not contain a valid package name" +class FileNotFoundInRepoError(HandlerException): + reason_for_failure = "Commented file not found in repo (likely renamed or deleted)" + def merge_download_lines(lines: list) -> list: """ Merges lines that are part of the same download block in Maven output.