diff options
author | Michael Hamann <michael@content-space.de> | 2013-07-21 22:59:27 +0200 |
---|---|---|
committer | Michael Hamann <michael@content-space.de> | 2013-07-21 23:31:13 +0200 |
commit | 6b0ec830e5ac0044252908630e52d4494f1df570 (patch) | |
tree | d2d19f1dacdd8093d28bbd6c3ca1eaf59d31f4f0 /lib/exe/js.php | |
parent | fbd8067eeeb9f424981aad8b283e17f734c738c3 (diff) | |
download | rpg-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/exe/js.php')
-rw-r--r-- | lib/exe/js.php | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/exe/js.php b/lib/exe/js.php index 4ff48133e..06769d895 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -104,10 +104,13 @@ function js_out(){ // load files foreach($files as $file){ $ismin = (substr($file,-7) == '.min.js'); + $debugjs = ($conf['allowdebug'] && strpos($file, DOKU_INC.'lib/scripts/') !== 0); echo "\n\n/* XXXXXXXXXX begin of ".str_replace(DOKU_INC, '', $file) ." XXXXXXXXXX */\n\n"; if($ismin) echo "\n/* BEGIN NOCOMPRESS */\n"; + if ($debugjs) echo "\ntry {\n"; js_load($file); + if ($debugjs) echo "\n} catch (e) {\n logError(e, '".str_replace(DOKU_INC, '', $file)."');\n}\n"; if($ismin) echo "\n/* END NOCOMPRESS */\n"; echo "\n\n/* XXXXXXXXXX end of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n"; } |