summaryrefslogtreecommitdiff
path: root/lib/scripts
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2013-07-21 22:59:27 +0200
committerMichael Hamann <michael@content-space.de>2013-07-21 23:31:13 +0200
commit6b0ec830e5ac0044252908630e52d4494f1df570 (patch)
treed2d19f1dacdd8093d28bbd6c3ca1eaf59d31f4f0 /lib/scripts
parentfbd8067eeeb9f424981aad8b283e17f734c738c3 (diff)
downloadrpg-6b0ec830e5ac0044252908630e52d4494f1df570.tar.gz
rpg-6b0ec830e5ac0044252908630e52d4494f1df570.tar.bz2
In debug mode: catch and log JS errors with file information
When debugging is enabled (allowdebug enabled) JS errors are now catched for each non-core JS file and logged with the additional information from which file they came. This should make it easier to find out which plugin is the cause for broken JS code. The feature isn't enabled by default as defining functions inside try-clauses isn't allowed in strict mode and causes a warning at least in Firefox.
Diffstat (limited to 'lib/scripts')
-rw-r--r--lib/scripts/helpers.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/scripts/helpers.js b/lib/scripts/helpers.js
index d6f36967d..fdac13b71 100644
--- a/lib/scripts/helpers.js
+++ b/lib/scripts/helpers.js
@@ -68,3 +68,18 @@ function bind(fnc/*, ... */) {
static_args.concat(Aps.call(arguments, 0)));
};
}
+
+/**
+ * Report an error from a JS file to the console
+ *
+ * @param e The error object
+ * @param file The file in which the error occurred
+ */
+function logError(e, file) {
+ if (window.console && console.error) {
+ console.error('The error "%s: %s" occurred in file "%s". ' +
+ 'If this is in a plugin try updating or disabling the plugin, ' +
+ 'if this is in a template try updating the template or switching to the "default" or "dokuwiki" template.',
+ e.name, e.message, file);
+ }
+} \ No newline at end of file