Skip to content

Commit

Permalink
updated error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
idalindegaard committed Dec 16, 2024
1 parent 1a4a9c8 commit 1df87af
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cg_lims/EPPs/files/femtopulse_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def get_data_and_write(
one numbered 1-12, one with the sample position/well for the run and
a column with the sample name or ladder (in the 12th position)."""

failed_samples: list = []

for artifact in artifacts:

artifact_name: str = artifact.samples[0].name
Expand All @@ -49,9 +51,20 @@ def get_data_and_write(
if index < 11:
SAMPLE_NAMES[index] = artifact_name
else:
raise InvalidValueError(f"Position {parsed_well} reserved for 'ladder', skipped.")
failed_samples.append({"artifact_name": artifact_name,
"parsed_well": parsed_well,
"error": "This position is reserved for the ladder"})
else:
raise InvalidValueError(f"Not possible position ({parsed_well}) for {artifact_name}, skipped.")
failed_samples.append({"artifact_name": artifact_name,
"parsed_well": parsed_well,
"error": "Position is not possible for the run"})

if failed_samples:
error_message: str = "\n".join(
f"Sample {sample['artifact_name']} in position {sample['parsed_well']}: {sample['error']}"
for sample in failed_samples
)
raise InvalidValueError(f"Errors found:\n{error_message}")

# The ladder will always be in well A12
SAMPLE_NAMES[-1] = "ladder"
Expand Down

0 comments on commit 1df87af

Please sign in to comment.