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;
};
+// 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,
var val;
- if (handle.type == 'object') {
+ if (handle.type === 'object') {
// The handle looks something like this:
// { handle: 8,
// type: 'object',
function SourceInfo(body) {
- var result = 'break in ';
+ var result = body.exception ? 'exception in ' : 'break in ';
if (body.script) {
if (body.script.name) {
result += ':';
result += body.sourceLine + 1;
+ if (body.exception) result += '\n' + body.exception.text;
+
return result;
}
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();
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