handle backtrace errors
authorFedor Indutny <fedor.indutny@gmail.com>
Sat, 24 Sep 2011 06:17:39 +0000 (13:17 +0700)
committerRyan Dahl <ry@tinyclouds.org>
Sun, 25 Sep 2011 18:58:22 +0000 (11:58 -0700)
lib/_debugger.js

index 4e3c9b2..a0e2cf8 100644 (file)
@@ -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 {