Bug 1458731 - Print actor's typeName and name of the throwing method when an exception is thrown by a protocol.js's actor. r=jryans
MozReview-Commit-ID: 5poQ0F1dJVu
--- a/devtools/shared/protocol.js
+++ b/devtools/shared/protocol.js
@@ -1007,20 +1007,21 @@ Actor.prototype = extend(Pool.prototype,
* @param [optional] string hint
* Optional string to customize the form.
* @returns A jsonable object.
*/
form: function(hint) {
return { actor: this.actorID };
},
- writeError: function(error) {
- console.error(error);
+ writeError: function(error, typeName, method) {
+ console.error(`Error while calling actor '${typeName}'s method '${method}'`,
+ error.message);
if (error.stack) {
- dump(error.stack);
+ console.error(error.stack);
}
this.conn.send({
from: this.actorID,
error: error.error || "unknownError",
message: error.message
});
},
@@ -1167,33 +1168,33 @@ var generateRequestHandlers = function(a
throw ex;
}
response.from = this.actorID;
// If spec.release has been specified, destroy the object.
if (spec.release) {
try {
this.destroy();
} catch (e) {
- this.writeError(e);
+ this.writeError(e, actorProto.typeName, spec.name);
return;
}
}
conn.send(response);
};
this._queueResponse(p => {
return p
.then(() => ret)
.then(sendReturn)
- .catch(e => this.writeError(e));
+ .catch(e => this.writeError(e, actorProto.typeName, spec.name));
});
} catch (e) {
this._queueResponse(p => {
- return p.then(() => this.writeError(e));
+ return p.then(() => this.writeError(e, actorProto.typeName, spec.name));
});
}
};
actorProto.requestTypes[spec.request.type] = handler;
});
return actorProto;