Skip to content

Commit

Permalink
prints error to console instead of crashing at None, -1 returned from…
Browse files Browse the repository at this point in the history
… Prospector
  • Loading branch information
lauraschauer committed Aug 16, 2024
1 parent c7dbd7f commit ba72de1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 7 additions & 1 deletion prospector/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ def main(argv): # noqa: C901
"enabled_rules": config.enabled_rules,
}

results, advisory_record = prospector(**params)
try:
results, advisory_record = prospector(**params)
except Exception as e:
ConsoleWriter.print(
f"Prospector function couldn't return successfully with {config.vuln_id}: {e}\n"
)
return

if config.preprocess_only:
return
Expand Down
8 changes: 3 additions & 5 deletions prospector/core/prospector.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,8 @@ def prospector( # noqa: C901
f"Number of candidates exceeds {limit_candidates}, aborting."
)

ConsoleWriter.print(
f"Candidates limitlimit exceeded: {len(candidates)}."
)
return None, len(candidates)
ConsoleWriter.print(f"Candidates limit exceeded: {len(candidates)}.")
raise Exception(f"Candidate limit exceeded: {len(candidates)}.")

with ExecutionTimer(
core_statistics.sub_collection("commit preprocessing")
Expand Down Expand Up @@ -232,7 +230,7 @@ def prospector( # noqa: C901
elapsed_time = time.time() - start_time
if elapsed_time > 1800:
logger.error("Processing timeout")
return None, len(candidates)
raise Exception("Processing timeout")

else:
writer.print("\nAll commits found in the backend")
Expand Down

0 comments on commit ba72de1

Please sign in to comment.