forked from manishthakur37/frappe-code-material
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcustom_error_log_send_email
More file actions
28 lines (23 loc) · 1.08 KB
/
custom_error_log_send_email
File metadata and controls
28 lines (23 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
except Exception as e:
print("Error:", e)
frappe.clear_messages()
# Create a new Flight Error Log document
error_log = frappe.new_doc("Flight Error Log")
error_log.title = str(e)
error_log.title_copy = str(e)
error_log.error = frappe.get_traceback()
error_log.insert(ignore_permissions=True)
frappe.db.commit()
send_error_email(str(e)) # Sending error message by email
return {"success_key": 0, "message": "Error creating customer"}
def send_error_email(error_message):
email_subject = "Error Creating Customer"
email_content = f"An error occurred while creating a customer. Details:\n\n{error_message}\n\nYou can view more details in the ERPNext system."
recipient = "flight.error@yopmail.com" # Enter the email address where you want to receive error notifications
sender = "manish.kumar@nestorbird.com" # Enter the email address of the sender
frappe.sendmail(
recipients=recipient,
sender=sender,
subject=email_subject,
message=email_content,
)