From 1c25d7c6f2934cf2d59aff232825047314b4b2ad Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 6 Jun 2022 14:28:40 +0530 Subject: [PATCH] fix(india): error while parsing e-invoice (backport #31053) (#31224) --- erpnext/regional/india/e_invoice/utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py index 7892a5003a8..9605d1d67b5 100644 --- a/erpnext/regional/india/e_invoice/utils.py +++ b/erpnext/regional/india/e_invoice/utils.py @@ -457,6 +457,8 @@ def make_einvoice(invoice): try: einvoice = safe_json_load(einvoice) einvoice = santize_einvoice_fields(einvoice) + except json.JSONDecodeError: + raise except Exception: show_link_to_error_log(invoice, einvoice) @@ -536,7 +538,14 @@ def safe_json_load(json_string): pos = e.pos start, end = max(0, pos-20), min(len(json_string)-1, pos+20) snippet = json_string[start:end] - frappe.throw(_("Error in input data. Please check for any special characters near following input:
{}").format(snippet)) + frappe.throw( + _( + "Error in input data. Please check for any special characters near following input:
{}" + ).format(snippet), + title=_("Invalid JSON"), + exc=e, + ) + def throw_error_list(errors, title): if len(errors) > 1: