Fail fast.
@@ -384,7 +384,6 @@ def anonymise_directory(
errors = []
for dicom_filepath in dicom_filepaths:
- try:
anonymise_file(
dicom_filepath,
delete_original_file=False,
@@ -393,9 +392,6 @@ def anonymise_directory(
keywords_to_leave_unchanged=keywords_to_leave_unchanged,
delete_private_tags=delete_private_tags,
delete_unknown_tags=delete_unknown_tags)
- except Exception as e:
- failing_filepaths.append(dicom_filepath)
- errors.append(e)
# Separate loop provides the ability to raise Exceptions from the
# unsuccessful deletion of the original DICOM files while preventing
@@ -405,12 +401,6 @@ def anonymise_directory(
if not dicom_filepath in failing_filepaths:
remove_file(dicom_filepath)
- for i, filepath in enumerate(failing_filepaths):
- raise Exception("Could not complete anonymisation of {}; a {} "
- "error was raised. For more details, try "
- "anonymising {} individually.\n"
- .format(filepath, type(errors[i]), filepath))
-
def anonymise_cli(args):
if args.delete_unknown_tags:
