Merge pull request #57535 from frappe/fix/silently-swallowed-exceptions

fix: stop swallowing exceptions silently in six places
This commit is contained in:
Mihir Kandoi
2026-07-28 13:06:46 +05:30
committed by GitHub
6 changed files with 33 additions and 35 deletions

View File

@@ -331,7 +331,7 @@ def add_bank_account(data, bank_account):
bank_account_loc = loc bank_account_loc = loc
for row in data[1:]: for row in data[1:]:
if bank_account_loc: if bank_account_loc is not None:
row[bank_account_loc] = bank_account row[bank_account_loc] = bank_account
else: else:
row.append(bank_account) row.append(bank_account)

View File

@@ -157,12 +157,9 @@ class BankTransactionRule(Document):
""" """
Delete the matched rule from the bank transaction Delete the matched rule from the bank transaction
""" """
try: frappe.db.set_value(
frappe.db.set_value( "Bank Transaction", {"matched_transaction_rule": self.name}, "matched_transaction_rule", None
"Bank Transaction", {"matched_transaction_rule": self.name}, "matched_transaction_rule", None )
)
except Exception:
pass
def after_delete(self): def after_delete(self):
""" """

View File

@@ -459,6 +459,11 @@ class PaymentRequest(Document):
else: else:
return True return True
except Exception: except Exception:
frappe.log_error(
title=f"Payment Gateway validation failed: {self.payment_gateway}",
reference_doctype=self.doctype,
reference_name=self.name,
)
return False return False
def set_payment_request_url(self): def set_payment_request_url(self):

View File

@@ -89,7 +89,11 @@ def filter_pricing_rule_based_on_condition(pricing_rules, doc=None):
if frappe.safe_eval(pricing_rule.condition, None, doc.as_dict()): if frappe.safe_eval(pricing_rule.condition, None, doc.as_dict()):
filtered_pricing_rules.append(pricing_rule) filtered_pricing_rules.append(pricing_rule)
except Exception: except Exception:
pass frappe.log_error(
title=f"Pricing Rule condition failed to evaluate: {pricing_rule.name}",
reference_doctype="Pricing Rule",
reference_name=pricing_rule.name,
)
else: else:
filtered_pricing_rules.append(pricing_rule) filtered_pricing_rules.append(pricing_rule)
else: else:

View File

@@ -403,12 +403,7 @@ def get_recipients_and_cc(customer, doc):
if doc.primary_mandatory and clist.primary_email: if doc.primary_mandatory and clist.primary_email:
for email in clist.primary_email.split(","): for email in clist.primary_email.split(","):
recipients.append(email.strip()) recipients.append(email.strip())
cc = [] cc = [email for user in doc.cc_to if (email := frappe.get_value("User", user.cc, "email"))]
if doc.cc_to != "":
try:
cc = [frappe.get_value("User", user.cc, "email") for user in doc.cc_to]
except Exception:
pass
return recipients, cc return recipients, cc

View File

@@ -64,27 +64,24 @@ def create_supplier_quotation(doc: str | Document | dict):
): ):
frappe.throw(_("Not Permitted"), frappe.PermissionError) frappe.throw(_("Not Permitted"), frappe.PermissionError)
try: sq_doc = frappe.get_doc(
sq_doc = frappe.get_doc( {
{ "doctype": "Supplier Quotation",
"doctype": "Supplier Quotation", "supplier": doc.get("supplier"),
"supplier": doc.get("supplier"), "terms": doc.get("terms"),
"terms": doc.get("terms"), "company": doc.get("company"),
"company": doc.get("company"), "currency": doc.get("currency")
"currency": doc.get("currency") or get_party_account_currency("Supplier", doc.get("supplier"), doc.get("company")),
or get_party_account_currency("Supplier", doc.get("supplier"), doc.get("company")), "buying_price_list": doc.get("buying_price_list")
"buying_price_list": doc.get("buying_price_list") or frappe.db.get_single_value("Buying Settings", "buying_price_list"),
or frappe.db.get_single_value("Buying Settings", "buying_price_list"), }
} )
) add_items(sq_doc, doc.get("supplier"), doc.get("items"))
add_items(sq_doc, doc.get("supplier"), doc.get("items")) sq_doc.flags.ignore_permissions = True
sq_doc.flags.ignore_permissions = True sq_doc.run_method("set_missing_values")
sq_doc.run_method("set_missing_values") sq_doc.save()
sq_doc.save() frappe.msgprint(_("Supplier Quotation {0} Created").format(sq_doc.name))
frappe.msgprint(_("Supplier Quotation {0} Created").format(sq_doc.name)) return sq_doc.name
return sq_doc.name
except Exception:
return None
def add_items(sq_doc, supplier, items): def add_items(sq_doc, supplier, items):