Frappe.throw does not work in curd event?

import frappe
from frappe import _
def after_insert(doc, method=None):
    try:
        frappe.errprint("Test1")
        if doc.party_type == "Customer":
            frappe.errprint("Test2")
            # this check if the button is submit and create gl entry and not worked like preview button
            path =  str(frappe.local.request.path)
            frappe.errprint(path)
            if path in ['/api/method/frappe.model.workflow.apply_workflow' ,'/api/method/frappe.desk.form.save.savedocs']:
                frappe.errprint("Test3")
            elif path in ['/api/method/erpnext.controllers.stock_controller.show_accounting_ledger_preview']:
                frappe.errprint("Test33")
                # pass
            else:
                frappe.errprint("Test3444")
                # /api/method/frappe.desk.form.save.cancel
                frappe.throw("Can not send sms Tell IT manager")
    except Exception as e:
        frappe.throw("Error: " + str(e))            

i try this code but the throw did not fire but the errprint fired?!

Remove your code from outside the try-catch block, then it will work.

could you explain it more to get it

i did this

def after_insert(doc, method=None):
    frappe.throw("test")

the error save in log and does not display in list view and display in form view

@manal_erpnext
You mean this doesn’t throw an error, but it creates a record in the error log? So, are you doing bulk operations?

yes doesn’t throw an error, but it creates a record in the error log

Yes, when jobs run in the background, they create error logs.
This is Expected behaviour of Frappe

but also must throw the error for user as other doctype like employee when i do bulk operation see the result and tell me what you see in log error and what throw to user
the throw show if it just 10 record