|
36 | 36 | V8_BREAKPOINT_ERROR: 'Unable to set breakpoint in v8', |
37 | 37 | SYNTAX_ERROR_IN_CONDITION: 'Syntax error in condition: ', |
38 | 38 | ERROR_EVALUATING_CONDITION: 'Error evaluating condition: ', |
| 39 | + ERROR_COMPILING_CONDITION: 'Error compiling condition.', |
39 | 40 | DISALLOWED_EXPRESSION: 'Expression not allowed', |
40 | 41 | SOURCE_MAP_URL_NOT_FOUND: 'The source map url could not be found in the compiled file', |
41 | 42 | SOURCE_MAP_READ_ERROR: 'The source map could not be read or was incorrectly formatted', |
@@ -132,7 +133,15 @@ module.exports.create = function(logger_, config_, fileStats_) { |
132 | 133 | }; |
133 | 134 | compile = getBreakpointCompiler(breakpoint); |
134 | 135 | if (breakpoint.condition && compile) { |
135 | | - breakpoint.condition = compile(breakpoint.condition); |
| 136 | + try { |
| 137 | + breakpoint.condition = compile(breakpoint.condition); |
| 138 | + } catch (e) { |
| 139 | + logger.info('Unable to compile condition >> ' + |
| 140 | + breakpoint.condition + ' <<'); |
| 141 | + return setErrorStatusAndCallback(cb, breakpoint, |
| 142 | + StatusMessage.BREAKPOINT_CONDITION, |
| 143 | + messages.ERROR_COMPILING_CONDITION); |
| 144 | + } |
136 | 145 | } |
137 | 146 | // TODO: more robust file finding of compiled files |
138 | 147 | scriptPath = scriptPath.substr(0, scriptPath.lastIndexOf('.')) + '.js'; |
@@ -323,16 +332,15 @@ module.exports.create = function(logger_, config_, fileStats_) { |
323 | 332 | switch(path.normalize(breakpoint.location.path).split('.').pop()) { |
324 | 333 | case 'coffee': |
325 | 334 | return function(uncompiled) { |
326 | | - try { |
327 | | - var comp = require('coffee-script'); |
328 | | - var compiled = comp.compile('0 || (' + uncompiled + ')'); |
329 | | - // Strip out coffeescript scoping wrapper to get translated condition |
330 | | - var re = /\(function\(\) {\s*0 \|\| \((.*)\);\n\n\}\)\.call\(this\);/; |
331 | | - var match = re.exec(compiled)[1]; |
332 | | - return match ? match.trim() : match; |
333 | | - } catch (err) { |
334 | | - logger.info('Unable to compile break or watch point >> ' + |
335 | | - uncompiled + ' <<', err); |
| 335 | + var comp = require('coffee-script'); |
| 336 | + var compiled = comp.compile('0 || (' + uncompiled + ')'); |
| 337 | + // Strip out coffeescript scoping wrapper to get translated condition |
| 338 | + var re = /\(function\(\) {\s*0 \|\| \((.*)\);\n\n\}\)\.call\(this\);/; |
| 339 | + var match = re.exec(compiled); |
| 340 | + if (match && match.length > 1) { |
| 341 | + return match[1].trim(); |
| 342 | + } else { |
| 343 | + throw new Error('Compilation Error for: ' + uncompiled); |
336 | 344 | } |
337 | 345 | }; |
338 | 346 | case 'es6': |
@@ -467,16 +475,29 @@ module.exports.create = function(logger_, config_, fileStats_) { |
467 | 475 | } |
468 | 476 |
|
469 | 477 | function captureBreakpointData(breakpoint, execState) { |
| 478 | + var expressionErrors = []; |
470 | 479 | if (breakpoint.expressions && breakpoints[breakpoint.id].compile) { |
471 | 480 | for (var i = 0; i < breakpoint.expressions.length; i++) { |
472 | | - breakpoint.expressions[i] = |
473 | | - breakpoints[breakpoint.id].compile(breakpoint.expressions[i]); |
| 481 | + try { |
| 482 | + breakpoint.expressions[i] = |
| 483 | + breakpoints[breakpoint.id].compile(breakpoint.expressions[i]); |
| 484 | + } catch (e) { |
| 485 | + logger.info('Unable to compile watch expression >> ' + |
| 486 | + breakpoint.expressions[i] + ' <<'); |
| 487 | + expressionErrors.push({ |
| 488 | + name: breakpoint.expressions[i], |
| 489 | + status: new StatusMessage(StatusMessage.VARIABLE_VALUE, |
| 490 | + 'Error Compiling Expression', true) |
| 491 | + }); |
| 492 | + breakpoint.expressions.splice(i, 1); |
| 493 | + } |
474 | 494 | } |
475 | 495 | } |
476 | 496 | var captured = state.capture(execState, breakpoint.expressions, config); |
477 | 497 | breakpoint.stackFrames = captured.stackFrames; |
478 | 498 | breakpoint.variableTable = captured.variableTable; |
479 | | - breakpoint.evaluatedExpressions = captured.evaluatedExpressions; |
| 499 | + breakpoint.evaluatedExpressions = |
| 500 | + expressionErrors.concat(captured.evaluatedExpressions); |
480 | 501 | } |
481 | 502 |
|
482 | 503 | /** |
|
0 commit comments