Skip to content
This repository
Browse code

Skip try-catch in ?debug mode

Test Plan:
Saw an exception in the network panel!

Auditors: eater
  • Loading branch information...
commit 4d08fd71224d9914789868daa9381eebff0f593c 1 parent 5719962
Ben Alpert authored

Showing 1 changed file with 19 additions and 11 deletions. Show diff stats Hide diff stats

  1. 30  utils/tmpl.js
30  utils/tmpl.js
@@ -283,7 +283,7 @@ $.tmpl = {
283 283
             ctx = {};
284 284
         }
285 285
 
286  
-        try {
  286
+        function doEval() {
287 287
             // Use the methods from JavaScript's built-in Math methods
288 288
             with (Math) {
289 289
                 // And the methods provided by the library
@@ -297,21 +297,29 @@ $.tmpl = {
297 297
                     }
298 298
                 }
299 299
             }
  300
+        }
300 301
 
301  
-        } catch (e) {
302  
-            var info;
  302
+        if (Khan.query.debug != null) {
  303
+            // Skip try-catch in debug mode so that the script panel works
  304
+            return doEval();
  305
+        } else {
  306
+            try {
  307
+                return doEval();
  308
+            } catch (e) {
  309
+                var info;
303 310
 
304  
-            if (elem.nodeName) {
305  
-                info = elem.nodeName.toLowerCase();
  311
+                if (elem.nodeName) {
  312
+                    info = elem.nodeName.toLowerCase();
306 313
 
307  
-                if (elem.id != null && elem.id.length > 0) {
308  
-                    info += "#" + elem.id;
  314
+                    if (elem.id != null && elem.id.length > 0) {
  315
+                        info += "#" + elem.id;
  316
+                    }
  317
+                } else {
  318
+                    info = JSON.stringify(code);
309 319
                 }
310  
-            } else {
311  
-                info = JSON.stringify(code);
312  
-            }
313 320
 
314  
-            Khan.error("Error while evaluating " + info, e);
  321
+                Khan.error("Error while evaluating " + info, e);
  322
+            }
315 323
         }
316 324
     },
317 325
 

0 notes on commit 4d08fd7

Please sign in to comment.
Something went wrong with that request. Please try again.