From: Fedor Indutny Date: Sat, 24 Sep 2011 06:17:39 +0000 (+0700) Subject: handle backtrace errors X-Git-Tag: v0.5.8~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b6acc27aad706505dff937e3b2ae6f8185b0995;p=platform%2Fupstream%2Fnodejs.git handle backtrace errors --- diff --git a/lib/_debugger.js b/lib/_debugger.js index 4e3c9b2..a0e2cf8 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -321,8 +321,8 @@ Client.prototype.reqEval = function(expression, cb) { } // Otherwise we need to get the current frame to see which scopes it has. - this.reqBacktrace(function(bt) { - if (!bt.frames) { + this.reqBacktrace(function(err, bt) { + if (err || !bt.frames) { // ?? cb({}); return; @@ -389,7 +389,7 @@ Client.prototype.reqFrameEval = function(expression, frame, cb) { // TODO: from, to, bottom Client.prototype.reqBacktrace = function(cb) { this.req({ command: 'backtrace' } , function(res) { - if (cb) cb(res.body); + if (cb) cb(!res.success && (res.message || true), res.body); }); }; @@ -585,7 +585,9 @@ Client.prototype.mirrorObject = function(handle, depth, cb) { Client.prototype.fullTrace = function(cb) { var self = this; - this.reqBacktrace(function(trace) { + this.reqBacktrace(function(err, trace) { + if (err) return cb(err); + var refs = []; for (var i = 0; i < trace.frames.length; i++) { @@ -620,7 +622,7 @@ Client.prototype.fullTrace = function(cb) { frame.receiver = res.body[frame.receiver.ref]; } - if (cb) cb(trace); + if (cb) cb(null, trace); }); }); }; @@ -1101,7 +1103,8 @@ Interface.prototype.backtrace = function() { client = this.client; self.pause(); - client.fullTrace(function(bt) { + client.fullTrace(function(err, bt) { + if (err) return self.error(err); if (bt.totalFrames == 0) { self.print('(empty stack)'); } else {