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(DX): capture tracebacks with context #39060

Merged
merged 1 commit into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
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 @@ -440,7 +440,7 @@ def reconcile(doc: None | str = None) -> None:
# Update the parent doc about the exception
frappe.db.rollback()

traceback = frappe.get_traceback()
traceback = frappe.get_traceback(with_context=True)
if traceback:
message = "Traceback: <br>" + traceback
frappe.db.set_value("Process Payment Reconciliation Log", log, "error_log", message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def start_payment_ledger_repost(docname=None):
except Exception as e:
frappe.db.rollback()

traceback = frappe.get_traceback()
traceback = frappe.get_traceback(with_context=True)
if traceback:
message = "Traceback: <br>" + traceback
frappe.db.set_value(repost_doc.doctype, repost_doc.name, "repost_error_log", message)
Expand Down
2 changes: 1 addition & 1 deletion erpnext/manufacturing/doctype/bom_creator/bom_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def create_boms(self):

frappe.msgprint(_("BOMs created successfully"))
except Exception:
traceback = frappe.get_traceback()
traceback = frappe.get_traceback(with_context=True)
self.db_set(
{
"status": "Failed",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,4 @@ def prepare_closing_stock_balance(name):
doc.db_set("status", "Completed")
except Exception as e:
doc.db_set("status", "Failed")
traceback = frappe.get_traceback()

frappe.log_error("Closing Stock Balance Failed", traceback, doc.doctype, doc.name)
doc.log_error(title="Closing Stock Balance Failed")
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def repost(doc):
raise

frappe.db.rollback()
traceback = frappe.get_traceback()
traceback = frappe.get_traceback(with_context=True)
doc.log_error("Unable to repost item valuation")

message = frappe.message_log.pop() if frappe.message_log else ""
Expand Down
2 changes: 1 addition & 1 deletion erpnext/stock/reorder_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _log_exception(mr):
exceptions_list.extend(frappe.local.message_log)
frappe.local.message_log = []
else:
exceptions_list.append(frappe.get_traceback())
exceptions_list.append(frappe.get_traceback(with_context=True))

mr.log_error("Unable to create material request")

Expand Down
4 changes: 2 additions & 2 deletions erpnext/utilities/bulk_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def retry_failed_transactions(failed_docs: list | None):
task(log.transaction_name, log.from_doctype, log.to_doctype)
except Exception as e:
frappe.db.rollback(save_point="before_creation_state")
update_log(log.name, "Failed", 1, str(frappe.get_traceback()))
update_log(log.name, "Failed", 1, str(frappe.get_traceback(with_context=True)))
else:
update_log(log.name, "Success", 1)

Expand All @@ -86,7 +86,7 @@ def job(deserialized_data, from_doctype, to_doctype):
fail_count += 1
create_log(
doc_name,
str(frappe.get_traceback()),
str(frappe.get_traceback(with_context=True)),
from_doctype,
to_doctype,
status="Failed",
Expand Down
Loading