Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correctly extract last message #37602

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def create_merge_logs(invoice_by_customer, closing_entry=None):
except Exception as e:
frappe.db.rollback()
message_log = frappe.message_log.pop() if frappe.message_log else str(e)
error_message = safe_load_json(message_log)
error_message = get_error_message(message_log)

if closing_entry:
closing_entry.set_status(update=True, status="Failed")
Expand Down Expand Up @@ -483,7 +483,7 @@ def cancel_merge_logs(merge_logs, closing_entry=None):
except Exception as e:
frappe.db.rollback()
message_log = frappe.message_log.pop() if frappe.message_log else str(e)
error_message = safe_load_json(message_log)
error_message = get_error_message(message_log)

if closing_entry:
closing_entry.set_status(update=True, status="Submitted")
Expand Down Expand Up @@ -525,10 +525,8 @@ def check_scheduler_status():
frappe.throw(_("Scheduler is inactive. Cannot enqueue job."), title=_("Scheduler Inactive"))


def safe_load_json(message):
def get_error_message(message) -> str:
try:
json_message = json.loads(message).get("message")
return message["message"]
except Exception:
json_message = message

return json_message
return str(message)
Loading