feat: add error logging to saving logic
This commit is contained in:
parent
51259f1fa9
commit
a22b15897c
2 changed files with 27 additions and 9 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from json import loads
|
||||
from json import loads, dumps
|
||||
from frappe import _, DoesNotExistError
|
||||
from frappe.boot import get_allowed_pages, get_allowed_reports
|
||||
from six import string_types
|
||||
|
|
@ -347,14 +347,27 @@ def save_customization(page, config):
|
|||
# Set label
|
||||
page_doc.label = page + '-' + frappe.session.user
|
||||
|
||||
if page_doc.is_new():
|
||||
page_doc.insert(ignore_permissions=True)
|
||||
else:
|
||||
page_doc.save(ignore_permissions=True)
|
||||
try:
|
||||
raise TypeError
|
||||
if page_doc.is_new():
|
||||
page_doc.insert(ignore_permissions=True)
|
||||
else:
|
||||
page_doc.save(ignore_permissions=True)
|
||||
except Exception as e:
|
||||
log = \
|
||||
"""
|
||||
page: {0}
|
||||
config: {1}
|
||||
exception: {2}
|
||||
""".format(page,
|
||||
dumps(config, sort_keys=True, indent=4), e)
|
||||
|
||||
frappe.log_error(log, _("Could not save customization"))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def prepare_widget(config, doctype, parentfield):
|
||||
if not config:
|
||||
return
|
||||
order = config.get('order')
|
||||
widgets = config.get('widgets')
|
||||
prepare_widget_list = []
|
||||
|
|
|
|||
|
|
@ -259,8 +259,13 @@ class DesktopPage {
|
|||
page: this.page_name,
|
||||
config: config
|
||||
}).then(res => {
|
||||
frappe.msgprint(__("Customizations Saved Successfully"));
|
||||
this.reload();
|
||||
if (res.message) {
|
||||
frappe.msgprint({ message: __("Customizations Saved Successfully"), title: __("Success")});
|
||||
this.reload();
|
||||
} else {
|
||||
frappe.throw({message: __("Something went wrong while saving customizations"), title:__("Failed")});
|
||||
this.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue