summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/framework/crash_manager.js
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2016-11-02 12:36:16 +0100
committerqsm-odoo <qsm@odoo.com>2016-11-02 13:26:00 +0100
commitdd560377e28ac9a8e39f56241bfff490ca7bce3f (patch)
tree745e7459b006cdc66fa971b3ba5f4e6bf5116d3e /addons/web/static/src/js/framework/crash_manager.js
parentc8d0fd4a50893535c7be0fb416e1f05a917e98d0 (diff)
[IMP] web: improve traceback reporting
* Do not assault the user with a full traceback on bug, but indicates an error occured and allow him to toggle the traceback * Automatically scroll the traceback to the end (better for python errors) * Propose the user to report the traceback by using a new "Copy" button which correctly copies the full error + traceback
Diffstat (limited to 'addons/web/static/src/js/framework/crash_manager.js')
-rw-r--r--addons/web/static/src/js/framework/crash_manager.js52
1 files changed, 41 insertions, 11 deletions
diff --git a/addons/web/static/src/js/framework/crash_manager.js b/addons/web/static/src/js/framework/crash_manager.js
index df21e87047c..af982ecd15d 100644
--- a/addons/web/static/src/js/framework/crash_manager.js
+++ b/addons/web/static/src/js/framework/crash_manager.js
@@ -37,7 +37,7 @@ var CrashManager = core.Class.extend({
if (this.connection_lost) {
return;
}
- if (error.code == -32098) {
+ if (error.code === -32098) {
core.bus.trigger('connection_lost');
this.connection_lost = true;
var timeinterval = setInterval(function() {
@@ -55,11 +55,11 @@ var CrashManager = core.Class.extend({
return;
}
if (error.data.name === "openerp.http.SessionExpiredException" || error.data.name === "werkzeug.exceptions.Forbidden") {
- this.show_warning({type: "Session Expired", data: { message: _t("Your Odoo session expired. Please refresh the current web page.") }});
+ this.show_warning({type: _t("Odoo Session Expired"), data: {message: _t("Your Odoo session expired. Please refresh the current web page.")}});
return;
}
if (_.has(map_title, error.data.exception_type)) {
- if(error.data.exception_type == 'except_orm'){
+ if(error.data.exception_type === 'except_orm'){
if(error.data.arguments[1]) {
error = _.extend({}, error,
{
@@ -93,7 +93,7 @@ var CrashManager = core.Class.extend({
}
this.show_warning(error);
- //InternalError
+ //InternalError
} else {
this.show_error(error);
@@ -105,23 +105,53 @@ var CrashManager = core.Class.extend({
}
new Dialog(this, {
size: 'medium',
- title: "Odoo " + (_.str.capitalize(error.type) || _t("Warning")),
+ title: _.str.capitalize(error.type || error.message) || _t("Odoo Warning"),
subtitle: error.data.title,
- $content: $('<div>').html(QWeb.render('CrashManager.warning', {error: error}))
+ $content: $(QWeb.render('CrashManager.warning', {error: error}))
}).open();
},
show_error: function(error) {
if (!this.active) {
return;
}
- new Dialog(this, {
- title: "Odoo " + _.str.capitalize(error.type),
- $content: QWeb.render('CrashManager.error', {error: error})
+ var dialog = new Dialog(this, {
+ title: _.str.capitalize(error.type || error.message) || _t("Odoo Error"),
+ $content: $(QWeb.render('CrashManager.error', {error: error}))
}).open();
+
+ // When the dialog opens, initialize the copy feature and destroy it when the dialog is closed
+ var $clipboardBtn;
+ var clipboard;
+ dialog.opened(function () {
+ $clipboardBtn = dialog.$(".o_clipboard_button");
+ $clipboardBtn.tooltip({title: _t("Copied !"), trigger: "manual", placement: "left"});
+ clipboard = new window.Clipboard($clipboardBtn[0], {
+ text: function () {
+ return (_t("Error") + ":\n" + error.message + "\n\n" + error.data.debug).trim();
+ }
+ });
+ clipboard.on("success", function (e) {
+ _.defer(function () {
+ $clipboardBtn.tooltip("show");
+ _.delay(function () {
+ $clipboardBtn.tooltip("hide");
+ }, 800);
+ });
+ });
+ });
+ dialog.on("closed", this, function () {
+ $clipboardBtn.tooltip("destroy");
+ clipboard.destroy();
+ });
+
+ // When the full traceback is shown, scroll it to the end (useful for better python error reporting)
+ dialog.$(".o_error_detail").on("shown.bs.collapse", function (e) {
+ e.target.scrollTop = e.target.scrollHeight;
+ });
},
show_message: function(exception) {
this.show_error({
- type: _t("Client Error"),
+ type: _t("Odoo Client Error"),
message: exception,
data: {debug: ""}
});
@@ -162,7 +192,7 @@ var RedirectWarningHandler = Dialog.extend(ExceptionHandler, {
new Dialog(this, {
size: 'medium',
- title: "Odoo " + (_.str.capitalize(error.type) || "Warning"),
+ title: _.str.capitalize(error.type) || _t("Odoo Warning"),
buttons: [
{text: error.data.arguments[2], classes : "btn-primary", click: function() {
window.location.href = '#action='+error.data.arguments[1];