fix: log unhandled exceptions in monitor log (#25897)

This commit is contained in:
Ankush Menat 2024-04-10 13:34:32 +05:30 committed by GitHub
parent 50fe31ca48
commit 0692496fd3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View file

@ -255,9 +255,10 @@ def execute_job(site, method, event, job_name, kwargs, user=None, is_async=True,
frappe.log_error(title=method_name)
raise
except Exception:
except Exception as e:
frappe.db.rollback()
frappe.log_error(title=method_name)
frappe.monitor.add_data_to_monitor(exception=e.__class__.__name__)
frappe.db.commit()
print(frappe.get_traceback())
raise

View file

@ -8,6 +8,7 @@ from collections import Counter
from contextlib import suppress
import frappe
from frappe.monitor import add_data_to_monitor
EXCLUDE_EXCEPTIONS = (
frappe.AuthenticationError,
@ -85,6 +86,7 @@ def log_error_snapshot(exception: Exception):
try:
log_error(title=str(exception), defer_insert=True)
logger.error("New Exception collected in error log")
add_data_to_monitor(exception=exception.__class__.__name__)
except Exception as e:
logger.error(f"Could not take error snapshot: {e}", exc_info=True)