Skip to content

Commit

Permalink
fix: better logging for unsuccessful mets file processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominick Leppich committed Nov 25, 2024
1 parent d489d4b commit c91dc12
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions migration/lib/mets_manipulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ def process_mets_file(self):
logging.error(error)
self.ctx.log_issue(self.file_path, error)
return

root = tree.getroot()
self.process_node(root)
try:
root = tree.getroot()
self.process_node(root)

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

def process_node(self, node):
if self.is_manual_id_reference(node):
Expand Down

0 comments on commit c91dc12

Please sign in to comment.