Frappe.throw (python) -> error: (JS) not executed, but with frappe.msgprint it is executed

Hi all,

I have a controller in Python that uses the frappe.throw function.
However in my js

frappe.call({

error: (r) => {
whatever code
}
})

The error function (“whatever code” above) is never executed.

If I use the frappe.msgprint(“message”, raise_exception=True) it is executed.
On the other hand, if I provide a frappe.exceptions.* exception instead of True when calling frappe.msgprint the error function is not executed.

Any idea, what I should do, if I want to use a specific exception class? frappe.msgpring always uses the ValidationError.

Thanks
DoCa

1 Like

Hello,

Same Issue I am facing.

I upgraded erpnext instance from version-14 to version-15.
And I found that Doctype " Job Requisition" on duplicate entry not showing error msg but only error sound is coming.

Previous Code ( frappe.throw ):

def validate(self):
		self.validate_duplicates()
		self.set_time_to_fill()

	def validate_duplicates(self):
		duplicate = frappe.db.exists(
			"Job Requisition",
			{
				"designation": self.designation,
				"department": self.department,
				"requested_by": self.requested_by,
				"status": ("not in", ["Cancelled", "Filled"]),
				"name": ("!=", self.name),
			},
		)

		if duplicate:
			frappe.throw(
				_("A Job Requisition for {0} requested by {1} already exists: {2}").format(
					frappe.bold(self.designation),
					frappe.bold(self.requested_by),
					get_link_to_form("Job Requisition", duplicate),
				),
				title=_("Duplicate Job Requisition"),
			)

After changing it to frappe.msgprint its working.

May I know why frappe.throw is not working.

Console Error: