From 7418905aef0c0fcbd13227526adc34f1e699fe45 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Sun, 18 Mar 2012 16:54:07 +0600 Subject: [PATCH] debugger: breakOnException Do not break automatically on exception, fixes #2926 --- lib/_debugger.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/_debugger.js b/lib/_debugger.js index 17ac52e57d..f454aa9c4c 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -678,6 +678,7 @@ var commands = [ 'kill', 'list', 'scripts', + 'breakOnException', 'breakpoints', 'version' ] @@ -1308,6 +1309,19 @@ Interface.prototype.watchers = function() { } }; +// Break on exception +Interface.prototype.breakOnException = function breakOnException() { + if (!this.requireConnection()) return; + + var self = this; + + // Break on exceptions + this.pause(); + this.client.reqSetExceptionBreak('all', function(err, res) { + self.resume(); + }); +}; + // Add breakpoint Interface.prototype.setBreakpoint = function(script, line, condition, silent) { @@ -1626,12 +1640,6 @@ Interface.prototype.trySpawn = function(cb) { self.setBreakpoint(bp.scriptId, bp.line, bp.condition, true); }); - // Break on exceptions - client.reqSetExceptionBreak('all', function(err, res) { - cb && cb(); - self.resume(); - }); - client.on('close', function() { self.pause(); self.print('program terminated'); @@ -1639,6 +1647,9 @@ Interface.prototype.trySpawn = function(cb) { self.client = null; self.killChild(); }); + + if (cb) cb(); + self.resume(); }); client.on('unhandledResponse', function(res) {