covered newly discovered edge case

This commit is contained in:
Karma Riuk
2025-03-23 11:15:44 +01:00
parent 1aa42c32cd
commit ad96cac750

View File

@ -135,6 +135,9 @@ class BuildHandler(ABC):
if not filepath.endswith('.java'): if not filepath.endswith('.java'):
raise NotJavaFileError(f"File '{filepath}' does not end with .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: with open(os.path.join(self.path, filepath)) as f:
try: try:
parsed_tree = javalang.parse.parse(f.read()) parsed_tree = javalang.parse.parse(f.read())
@ -360,6 +363,9 @@ class NotJavaFileError(HandlerException):
class NoPackageFoundError(HandlerException): class NoPackageFoundError(HandlerException):
reason_for_failure = "Java file did not contain a valid package name" 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: def merge_download_lines(lines: list) -> list:
""" """
Merges lines that are part of the same download block in Maven output. Merges lines that are part of the same download block in Maven output.