summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-04-01 15:30:42 +0200
committerJo-Philipp Wich <jo@mein.io>2019-07-07 15:25:49 +0200
commit5b7924c8087b93037ae20e03f35bd0c7e9e06a05 (patch)
tree82ecd94ab3e77e63c48b051890be54cd970786e3 /modules/luci-base
parentfda4ba598c0ba1c06f5de43554b40cf0d415d047 (diff)
luci-base: luci.js: tweak error handling
If the ui class is loaded, use its modalDialog facility to display runtime errors, alternatively render them into the maincontent area. Also prevent duplication of stack trace information and throw a low level error on session expiration to allow higher layers to properly handle it. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/luci.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js
index 07e8d8c887..c71865f96f 100644
--- a/modules/luci-base/htdocs/luci-static/resources/luci.js
+++ b/modules/luci-base/htdocs/luci-static/resources/luci.js
@@ -488,12 +488,22 @@
}
/* Append shortened & beautified stacktrace to message */
- e.message += '\n' + stack.join('\n')
+ var trace = stack.join('\n')
.replace(/(.*?)@(.+):(\d+):(\d+)/g, ' at $1 ($2:$3:$4)');
+ if (e.message.indexOf(trace) == -1)
+ e.message += '\n' + trace;
+
if (window.console && console.debug)
console.debug(e);
+ if (this.ui)
+ this.ui.showModal(_('Runtime error'),
+ E('pre', { 'class': 'alert-message error' }, e));
+ else
+ L.dom.content(document.querySelector('#maincontent'),
+ E('pre', { 'class': 'alert-message error' }, e));
+
throw e;
},
@@ -610,7 +620,7 @@
}, _('To login…')))
]);
- L.error('AuthenticationError', 'Session expired');
+ throw 'Session expired';
});
originalCBIInit();