Skip to content

Commit

Permalink
fix: gacefully handle parsing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Oct 1, 2024
1 parent 22af1eb commit d540d03
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion erpnext/edi/doctype/code_list/code_list_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ def import_genericode():

# Parse the uploaded file content
parser = etree.XMLParser(remove_blank_text=True)
root = etree.fromstring(frappe.local.uploaded_file, parser=parser)
try:
root = etree.fromstring(frappe.local.uploaded_file, parser=parser)
except Exception as e:
frappe.throw(f"<pre>{e!s}</pre>", title=_("Parsing Error"))

# Extract the name (CanonicalVersionUri) from the parsed XML
name = root.find(".//CanonicalVersionUri").text
Expand Down

0 comments on commit d540d03

Please sign in to comment.