Skip to content

Commit c91dc12

Browse files
author
Dominick Leppich
committed
fix: better logging for unsuccessful mets file processing
1 parent d489d4b commit c91dc12

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

migration/lib/mets_manipulator.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,18 @@ def process_mets_file(self):
3737
logging.error(error)
3838
self.ctx.log_issue(self.file_path, error)
3939
return
40-
41-
root = tree.getroot()
42-
self.process_node(root)
40+
try:
41+
root = tree.getroot()
42+
self.process_node(root)
4343

44-
if self.changed and not self.ctx.dry:
45-
self.create_backup()
46-
tree.write(self.file_path, encoding='utf-8', xml_declaration=True)
47-
self.ctx.log_processed(self.file_path)
44+
if self.changed and not self.ctx.dry:
45+
self.create_backup()
46+
tree.write(self.file_path, encoding='utf-8', xml_declaration=True)
47+
self.ctx.log_processed(self.file_path)
48+
except Exception as e:
49+
error = f'Something very unexpected happened during processing of mets file {self.file_path}: {e}'
50+
logging.critical(error)
51+
raise Exception(error)
4852

4953
def process_node(self, node):
5054
if self.is_manual_id_reference(node):

0 commit comments

Comments
 (0)