Merge pull request #689 from anandpdoshi/error-reporting
Added Error Reporting
This commit is contained in:
commit
4b3fbc3265
5 changed files with 66 additions and 12 deletions
|
|
@ -65,6 +65,8 @@ def get_bootinfo():
|
|||
if bootinfo.lang:
|
||||
bootinfo.lang = unicode(bootinfo.lang)
|
||||
|
||||
bootinfo.error_report_email = frappe.get_hooks("error_report_email")
|
||||
|
||||
return bootinfo
|
||||
|
||||
def load_conf_settings(bootinfo):
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ STANDARD_USERS = ("Guest", "Administrator")
|
|||
from frappe.model.document import Document
|
||||
|
||||
class User(Document):
|
||||
|
||||
def autoname(self):
|
||||
"""set name as email id"""
|
||||
if self.name not in STANDARD_USERS:
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ app_description = "Full Stack Web Application Framwork in Python"
|
|||
app_icon = "assets/frappe/images/frappe.svg"
|
||||
app_version = __version__
|
||||
app_color = "#3498db"
|
||||
app_email = "support@frappe.io"
|
||||
|
||||
before_install = "frappe.utils.install.before_install"
|
||||
after_install = "frappe.utils.install.after_install"
|
||||
|
|
|
|||
|
|
@ -68,10 +68,10 @@ frappe.request.call = function(opts) {
|
|||
if(typeof data === "string") data = JSON.parse(data);
|
||||
opts.error && opts.error(data, xhr.responseText);
|
||||
},
|
||||
500: function() {
|
||||
500: function(xhr) {
|
||||
msgprint(__("Server Error: Please check your server logs or contact tech support."))
|
||||
opts.error && opts.error();
|
||||
|
||||
frappe.request.report_error(xhr, opts);
|
||||
}
|
||||
},
|
||||
async: opts.async
|
||||
|
|
@ -174,7 +174,9 @@ frappe.request.cleanup = function(opts, r) {
|
|||
r.exc = JSON.parse(r.exc);
|
||||
if(r.exc instanceof Array) {
|
||||
$.each(r.exc, function(i, v) {
|
||||
if(v)console.log(v);
|
||||
if(v) {
|
||||
console.log(v);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log(r.exc);
|
||||
|
|
@ -210,3 +212,44 @@ frappe.request.cleanup = function(opts, r) {
|
|||
|
||||
frappe.last_response = r;
|
||||
}
|
||||
|
||||
frappe.request.report_error = function(xhr, request_opts) {
|
||||
var data = JSON.parse(xhr.responseText);
|
||||
if (data.exc) {
|
||||
var exc = (JSON.parse(data.exc) || []).join("\n");
|
||||
delete data.exc;
|
||||
} else {
|
||||
var exc = "";
|
||||
}
|
||||
|
||||
if (exc) {
|
||||
var error_report_email = (frappe.boot.error_report_email || []).join(", ");
|
||||
var error_message = '<div><a class="report-btn"><i class="icon-fixed-width icon-envelope"></i> '
|
||||
+ __("Report this issue") + '</a>'
|
||||
+ '<pre style="max-height: 300px; margin-top: 7px;">' + exc + '</pre></div>';
|
||||
|
||||
var msg_dialog = msgprint(error_message);
|
||||
|
||||
msg_dialog.msg_area.find(".report-btn")
|
||||
.toggle(error_report_email ? true : false)
|
||||
.on("click", function() {
|
||||
var error_report_message = [
|
||||
'<h5>Error Report</h5>',
|
||||
'<pre>' + exc + '</pre>',
|
||||
'<hr>',
|
||||
'<h5>Request Data</h5>',
|
||||
'<pre>' + JSON.stringify(request_opts, null, "\t") + '</pre>',
|
||||
'<hr>',
|
||||
'<h5>Response JSON</h5>',
|
||||
'<pre>' + JSON.stringify(data, null, '\t')+ '</pre>'
|
||||
].join("\n");
|
||||
|
||||
var communication_composer = new frappe.views.CommunicationComposer({
|
||||
subject: 'Error Report',
|
||||
recipients: error_report_email,
|
||||
message: error_report_message
|
||||
});
|
||||
communication_composer.dialog.$wrapper.css("z-index", cint(msg_dialog.$wrapper.css("z-index")) + 1);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -260,13 +260,20 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
|
||||
// select print format
|
||||
$(fields.select_print_format.wrapper).toggle(false);
|
||||
$(fields.select_print_format.input)
|
||||
.empty()
|
||||
.add_options(cur_frm.print_formats)
|
||||
.val(cur_frm.print_formats[0]);
|
||||
|
||||
if (cur_frm) {
|
||||
$(fields.select_print_format.input)
|
||||
.empty()
|
||||
.add_options(cur_frm.print_formats)
|
||||
.val(cur_frm.print_formats[0]);
|
||||
} else {
|
||||
$(fields.attach_document_print.wrapper).toggle(false);
|
||||
}
|
||||
|
||||
},
|
||||
setup_attach: function() {
|
||||
if (!cur_frm) return;
|
||||
|
||||
var fields = this.dialog.fields_dict;
|
||||
var attach = $(fields.select_attachments.wrapper);
|
||||
|
||||
|
|
@ -366,10 +373,12 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
msgprint(__("Email sent to {0}", [form_values.recipients]));
|
||||
me.dialog.hide();
|
||||
|
||||
if (cur_frm.docname && (frappe.last_edited_communication[cur_frm.doctype] || {})[cur_frm.docname]) {
|
||||
delete frappe.last_edited_communication[cur_frm.doctype][cur_frm.docname];
|
||||
if (cur_frm) {
|
||||
if (cur_frm.docname && (frappe.last_edited_communication[cur_frm.doctype] || {})[cur_frm.docname]) {
|
||||
delete frappe.last_edited_communication[cur_frm.doctype][cur_frm.docname];
|
||||
}
|
||||
cur_frm.reload_doc();
|
||||
}
|
||||
cur_frm.reload_doc();
|
||||
} else {
|
||||
msgprint(__("There were errors while sending email. Please try again."));
|
||||
}
|
||||
|
|
@ -379,7 +388,7 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
|
||||
setup_earlier_reply: function() {
|
||||
var fields = this.dialog.fields_dict;
|
||||
var comm_list = cur_frm.communication_view
|
||||
var comm_list = (cur_frm && cur_frm.communication_view)
|
||||
? cur_frm.communication_view.list
|
||||
: [];
|
||||
var signature = frappe.boot.user.email_signature || "";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue