Skip to content

Commit 76c3da9

Browse files
committed
tidy
1 parent 7f2ca44 commit 76c3da9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

recordprocessor/src/batch_processor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ def process_csv_to_fhir(incoming_message_body: dict) -> None:
5050
logger.info(f"process with encoder {encoder} from row {row_count+1}")
5151
row_count, err = process_rows(file_id, vaccine, supplier, file_key, allowed_operations,
5252
created_at_formatted_string, csv_reader, target_disease)
53+
5354
if err:
54-
logger.warning(f"Error processing: {err}.")
55-
# check if it's a decode error
56-
if err.reason == "invalid continuation byte":
55+
logger.warning(f"Processing Error: {err}.")
56+
if isinstance(err, InvalidEncoding):
5757
new_encoder = "cp1252"
5858
logger.info(f"Encode error at row {row_count} with {encoder}. Switch to {new_encoder}")
5959
encoder = new_encoder
@@ -108,7 +108,7 @@ def process_rows(file_id, vaccine, supplier, file_key, allowed_operations, creat
108108
# if error reason is 'invalid continuation byte', then it's a decode error
109109
logger.error("Error processing row %s: %s", row_count, error)
110110
if hasattr(error, 'reason') and error.reason == "invalid continuation byte":
111-
return total_rows_processed_count, error
111+
return total_rows_processed_count, InvalidEncoding("Invalid continuation byte")
112112
else:
113113
raise error
114114
return total_rows_processed_count, None

recordprocessor/tests/test_recordprocessor_edge_cases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_process_large_file_with_cp1252(self):
7777
# check logger.warning called for decode error
7878
self.mock_logger_warning.assert_called()
7979
warning_call_args = self.mock_logger_warning.call_args[0][0]
80-
self.assertTrue(warning_call_args.startswith("Error processing: 'utf-8' codec can't decode byte"))
80+
self.assertEqual(warning_call_args, "Processing Error: Invalid continuation byte.")
8181

8282
def test_process_large_file_with_utf8(self):
8383
""" Test processing a large file with utf-8 encoding """

0 commit comments

Comments
 (0)