Skip to content

Commit 5c96472

Browse files
refactor: ensure traceback in broad exceptions
1 parent cdd5fc8 commit 5c96472

2 files changed

Lines changed: 12 additions & 23 deletions

File tree

src/dve/pipeline/foundry_ddb_pipeline.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ def file_transformation(
5757
try:
5858
return super().file_transformation(submission_info)
5959
except Exception as exc: # pylint: disable=W0718
60-
self._logger.error(f"File transformation raised exception: {exc}")
61-
self._logger.exception(exc)
60+
self._logger.exception("File transformation raised exception:")
6261
dump_processing_errors(
6362
fh.joinuri(self.processed_files_path, submission_info.submission_id),
6463
"file_transformation",
@@ -73,8 +72,7 @@ def apply_data_contract(
7372
try:
7473
return super().apply_data_contract(submission_info, submission_status)
7574
except Exception as exc: # pylint: disable=W0718
76-
self._logger.error(f"Apply data contract raised exception: {exc}")
77-
self._logger.exception(exc)
75+
self._logger.exception("Apply data contract raised exception:")
7876
dump_processing_errors(
7977
fh.joinuri(self.processed_files_path, submission_info.submission_id),
8078
"contract",
@@ -89,8 +87,7 @@ def apply_business_rules(
8987
try:
9088
return super().apply_business_rules(submission_info, submission_status)
9189
except Exception as exc: # pylint: disable=W0718
92-
self._logger.error(f"Apply business rules raised exception: {exc}")
93-
self._logger.exception(exc)
90+
self._logger.exception("Apply business rules raised exception:")
9491
dump_processing_errors(
9592
fh.joinuri(self.processed_files_path, submission_info.submission_id),
9693
"business_rules",
@@ -105,8 +102,7 @@ def error_report(
105102
try:
106103
return super().error_report(submission_info, submission_status)
107104
except Exception as exc: # pylint: disable=W0718
108-
self._logger.error(f"Error reports raised exception: {exc}")
109-
self._logger.exception(exc)
105+
self._logger.exception("Error reports raised exception:")
110106
sub_stats = None
111107
report_uri = None
112108
dump_processing_errors(

src/dve/pipeline/pipeline.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,7 @@ def audit_received_file_step(
244244
)
245245
continue
246246
except Exception as exc: # pylint: disable=W0703
247-
self._logger.error(f"audit_received_file raised exception: {exc}")
248-
self._logger.exception(exc)
247+
self._logger.exception("audit_received_file raised exception:")
249248
dump_processing_errors(
250249
fh.joinuri(self.processed_files_path, submission_id),
251250
"audit_received",
@@ -301,8 +300,7 @@ def file_transformation(
301300
)
302301

303302
except MessageBearingError as exc:
304-
self._logger.error(f"Unexpected file transformation error: {exc}")
305-
self._logger.exception(exc)
303+
self._logger.exception("Unexpected file transformation error:")
306304
errors.extend(exc.messages)
307305

308306
if errors:
@@ -352,8 +350,7 @@ def file_transformation_step(
352350
)
353351
continue
354352
except Exception as exc: # pylint: disable=W0703
355-
self._logger.error(f"File transformation raised exception: {exc}")
356-
self._logger.exception(exc)
353+
self._logger.exception("File transformation raised exception:")
357354
dump_processing_errors(
358355
fh.joinuri(self.processed_files_path, sub_info.submission_id),
359356
"file_transformation",
@@ -478,8 +475,7 @@ def data_contract_step(
478475
)
479476
continue
480477
except Exception as exc: # pylint: disable=W0703
481-
self._logger.error(f"Data Contract raised exception: {exc}")
482-
self._logger.exception(exc)
478+
self._logger.exception("Data Contract raised exception:")
483479
dump_processing_errors(
484480
fh.joinuri(self.processed_files_path, sub_info.submission_id),
485481
"contract",
@@ -644,8 +640,7 @@ def business_rule_step(
644640
)
645641
continue
646642
except Exception as exc: # pylint: disable=W0703
647-
self._logger.error(f"Business Rules raised exception: {exc}")
648-
self._logger.exception(exc)
643+
self._logger.exception("Business Rules raised exception:")
649644
dump_processing_errors(
650645
fh.joinuri(self.processed_files_path, sub_info.submission_id),
651646
"business_rules",
@@ -704,9 +699,8 @@ def _get_error_dataframes(self, submission_id: str):
704699
errors = None
705700
try:
706701
errors = json.load(f)
707-
except UnicodeDecodeError as exc:
708-
self._logger.error(f"Error reading file: {file}")
709-
self._logger.exception(exc)
702+
except UnicodeDecodeError:
703+
self._logger.exception(f"Error reading file: {file}")
710704
continue
711705
if not errors:
712706
continue
@@ -845,8 +839,7 @@ def error_report_step(
845839
)
846840
continue
847841
except Exception as exc: # pylint: disable=W0703
848-
self._logger.error(f"Error reports raised exception: {exc}")
849-
self._logger.exception(exc)
842+
self._logger.exception("Error reports raised exception:")
850843
dump_processing_errors(
851844
fh.joinuri(self.processed_files_path, sub_info.submission_id),
852845
"error_report",

0 commit comments

Comments
 (0)