fix: Create error log if something goes wrong while call log creation (#19055)

* fix: Create error log if something goes wrong while call log creation

- For better debbugging

* fix: Rollback if any error occurs during call log creation
This commit is contained in:
Suraj Shetty
2019-09-17 15:53:23 +05:30
committed by Nabin Hait
parent f9069a9873
commit af2eac4334

View File

@@ -1,5 +1,6 @@
import frappe import frappe
import requests import requests
from frappe import _
# api/method/erpnext.erpnext_integrations.exotel_integration.handle_incoming_call # api/method/erpnext.erpnext_integrations.exotel_integration.handle_incoming_call
# api/method/erpnext.erpnext_integrations.exotel_integration.handle_end_call # api/method/erpnext.erpnext_integrations.exotel_integration.handle_end_call
@@ -7,6 +8,7 @@ import requests
@frappe.whitelist(allow_guest=True) @frappe.whitelist(allow_guest=True)
def handle_incoming_call(**kwargs): def handle_incoming_call(**kwargs):
try:
exotel_settings = get_exotel_settings() exotel_settings = get_exotel_settings()
if not exotel_settings.enabled: return if not exotel_settings.enabled: return
@@ -20,6 +22,10 @@ def handle_incoming_call(**kwargs):
create_call_log(call_payload) create_call_log(call_payload)
else: else:
update_call_log(call_payload, call_log=call_log) update_call_log(call_payload, call_log=call_log)
except Exception as e:
frappe.db.rollback()
frappe.log_error(title=_('Error in Exotel incoming call'))
frappe.db.commit()
@frappe.whitelist(allow_guest=True) @frappe.whitelist(allow_guest=True)
def handle_end_call(**kwargs): def handle_end_call(**kwargs):