Better error when serializing catalog to XML fails

This commit is contained in:
Kovid Goyal 2023-05-04 22:15:17 +05:30
parent 1cc6f9eb7b
commit 4f364dc351
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -177,6 +177,7 @@ class CSV_XML(CatalogPlugin):
else: else:
root = E.calibredb() root = E.calibredb()
for r in data: for r in data:
try:
record = E.record() record = E.record()
root.append(record) root.append(record)
@ -243,6 +244,8 @@ class CSV_XML(CatalogPlugin):
if 'library_name' in fields: if 'library_name' in fields:
record.append(E.library_name(current_library)) record.append(E.library_name(current_library))
except Exception as e:
raise Exception('Failed to convert {} to XML with error: {}'.format(r['title'], e)) from e
with open(path_to_output, 'wb') as f: with open(path_to_output, 'wb') as f:
f.write(etree.tostring(root, encoding='utf-8', f.write(etree.tostring(root, encoding='utf-8',