parent
a239ea0d40
commit
80858761a8
@ -236,6 +236,10 @@ Client.prototype._onResponse = function(res) {
|
||||
this.emit('break', res.body);
|
||||
handled = true;
|
||||
|
||||
} else if (res.body && res.body.event == 'exception') {
|
||||
this.emit('exception', res.body);
|
||||
handled = true;
|
||||
|
||||
} else if (res.body && res.body.event == 'afterCompile') {
|
||||
this._addHandle(res.body.body.script);
|
||||
handled = true;
|
||||
@ -409,6 +413,16 @@ Client.prototype.reqBacktrace = function(cb) {
|
||||
};
|
||||
|
||||
|
||||
// reqSetExceptionBreak(type, cb)
|
||||
// TODO: from, to, bottom
|
||||
Client.prototype.reqSetExceptionBreak = function(type, cb) {
|
||||
this.req({
|
||||
command: 'setexceptionbreak',
|
||||
arguments: { type: type, enabled: true }
|
||||
}, cb);
|
||||
};
|
||||
|
||||
|
||||
// Returns an array of objects like this:
|
||||
//
|
||||
// { handle: 11,
|
||||
@ -495,7 +509,7 @@ Client.prototype.mirrorObject = function(handle, depth, cb) {
|
||||
|
||||
var val;
|
||||
|
||||
if (handle.type == 'object') {
|
||||
if (handle.type === 'object') {
|
||||
// The handle looks something like this:
|
||||
// { handle: 8,
|
||||
// type: 'object',
|
||||
@ -695,7 +709,7 @@ function SourceUnderline(sourceText, position, tty) {
|
||||
|
||||
|
||||
function SourceInfo(body) {
|
||||
var result = 'break in ';
|
||||
var result = body.exception ? 'exception in ' : 'break in ';
|
||||
|
||||
if (body.script) {
|
||||
if (body.script.name) {
|
||||
@ -715,6 +729,8 @@ function SourceInfo(body) {
|
||||
result += ':';
|
||||
result += body.sourceLine + 1;
|
||||
|
||||
if (body.exception) result += '\n' + body.exception.text;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1599,9 +1615,11 @@ Interface.prototype.trySpawn = function(cb) {
|
||||
self.setBreakpoint(bp.scriptId, bp.line, bp.condition, true);
|
||||
});
|
||||
|
||||
if (cb) cb();
|
||||
|
||||
self.resume();
|
||||
// Break on exceptions
|
||||
client.reqSetExceptionBreak('all', function(err, res) {
|
||||
cb && cb();
|
||||
self.resume();
|
||||
});
|
||||
|
||||
client.on('close', function() {
|
||||
self.pause();
|
||||
@ -1622,6 +1640,10 @@ Interface.prototype.trySpawn = function(cb) {
|
||||
self.handleBreak(res.body);
|
||||
});
|
||||
|
||||
client.on('exception', function(res) {
|
||||
self.handleBreak(res.body);
|
||||
});
|
||||
|
||||
client.on('error', connectError);
|
||||
function connectError() {
|
||||
// If it's failed to connect 4 times then don't catch the next error
|
||||
|
Loading…
x
Reference in New Issue
Block a user