Merge pull request #2150 from nabinhait/hotfix

Add error traceback in comment if no message_log
This commit is contained in:
Nabin Hait 2016-10-05 16:45:49 +05:30 committed by GitHub
commit 7b3bf9ffd7

View file

@ -999,8 +999,12 @@ def execute_action(doctype, name, action, **kwargs):
getattr(doc, action)(**kwargs)
except frappe.ValidationError:
# add a comment (?)
doc.add_comment('Comment',
_('Action Failed') + '<br><br>' + json.loads(frappe.local.message_log[-1]).get('message'))
if frappe.local.message_log:
msg = json.loads(frappe.local.message_log[-1]).get('message')
else:
msg = '<pre><code>' + frappe.get_traceback() + '</pre></code>'
doc.add_comment('Comment', _('Action Failed') + '<br><br>' + msg)
doc.notify_update()
except Exception: