|
8 | 8 | from send_to_kinesis import send_to_kinesis |
9 | 9 | from clients import logger |
10 | 10 | from file_level_validation import file_level_validation |
11 | | -from errors import NoOperationPermissions, InvalidHeaders, InvalidEncoding |
| 11 | +from errors import NoOperationPermissions, InvalidHeaders |
12 | 12 | from utils_for_recordprocessor import get_csv_content_dict_reader |
13 | 13 | from typing import Optional |
14 | 14 |
|
@@ -43,7 +43,7 @@ def process_csv_to_fhir(incoming_message_body: dict) -> int: |
43 | 43 | created_at_formatted_string, csv_reader, target_disease) |
44 | 44 |
|
45 | 45 | if err: |
46 | | - if isinstance(err, InvalidEncoding): |
| 46 | + if isinstance(err, UnicodeDecodeError): |
47 | 47 | """ resolves encoding issue VED-754 """ |
48 | 48 | logger.warning(f"Encoding Error: {err}.") |
49 | 49 | new_encoder = "cp1252" |
@@ -95,13 +95,10 @@ def process_rows(file_id, vaccine, supplier, file_key, allowed_operations, creat |
95 | 95 | send_to_kinesis(supplier, outgoing_message_body, vaccine) |
96 | 96 | total_rows_processed_count += 1 |
97 | 97 |
|
98 | | - except Exception as error: # pylint: disable=broad-exception-caught |
99 | | - # if error reason is 'invalid continuation byte', then it's a decode error |
| 98 | + except UnicodeDecodeError as error: # pylint: disable=broad-exception-caught |
100 | 99 | logger.error("Error processing row %s: %s", row_count, error) |
101 | | - if hasattr(error, 'reason') and error.reason == "invalid continuation byte": |
102 | | - return total_rows_processed_count, InvalidEncoding("Invalid continuation byte") |
103 | | - else: |
104 | | - raise error |
| 100 | + return total_rows_processed_count, error |
| 101 | + |
105 | 102 | return total_rows_processed_count, None |
106 | 103 |
|
107 | 104 |
|
|
0 commit comments