From d540d03d8a5903764c311b8d19c3d7cb3188e6d9 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 1 Oct 2024 12:13:55 +0200 Subject: [PATCH] fix: gacefully handle parsing errors --- erpnext/edi/doctype/code_list/code_list_import.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/edi/doctype/code_list/code_list_import.py b/erpnext/edi/doctype/code_list/code_list_import.py index f6a00b953096..297b9a76db4a 100644 --- a/erpnext/edi/doctype/code_list/code_list_import.py +++ b/erpnext/edi/doctype/code_list/code_list_import.py @@ -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"
{e!s}
", title=_("Parsing Error")) # Extract the name (CanonicalVersionUri) from the parsed XML name = root.find(".//CanonicalVersionUri").text