Bug 1253976 - Protocol.js error packets should have meaningful `error` and `message` fields;r=jryans
authorEddy Bruel <ejpbruel@mozilla.com>
Fri, 01 Apr 2016 09:17:50 +0200
changeset 291339 587a80aed81e49b6c7df3117b66d15e2793b9406
parent 291338 76e4e7620f839730994c6b9242ed78b648795409
child 291340 4f09dd6aa299804f73f654c1357ffc43d3bc3d8e
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1253976
milestone48.0a1
Bug 1253976 - Protocol.js error packets should have meaningful `error` and `message` fields;r=jryans
devtools/server/actors/environment.js
devtools/server/actors/source.js
devtools/server/protocol.js
--- a/devtools/server/actors/environment.js
+++ b/devtools/server/actors/environment.js
@@ -86,17 +86,20 @@ let EnvironmentActor = ActorClass({
                message: "Changing the value of an immutable binding is not " +
                         "allowed" };
     }*/
 
     try {
       this.obj.setVariable(name, value);
     } catch (e) {
       if (e instanceof Debugger.DebuggeeWouldRun) {
-        throw new Error("Assigning a value would cause the debuggee to run");
+        throw {
+          error: "threadWouldRun",
+          message: "Assigning a value would cause the debuggee to run"
+        };
       } else {
         throw e;
       }
     }
     return { from: this.actorID };
   }, {
     request: {
       name: Arg(1),
--- a/devtools/server/actors/source.js
+++ b/devtools/server/actors/source.js
@@ -603,17 +603,20 @@ let SourceActor = ActorClass({
    *        A JSON object representing the request.
    *
    * @returns Promise
    *          A promise that resolves to a JSON object representing the
    *          response.
    */
   setBreakpoint: method(function (line, column, condition) {
     if (this.threadActor.state !== "paused") {
-      throw new Error("Cannot set breakpoint while debuggee is running.");
+      throw {
+        error: "wrongState",
+        message: "Cannot set breakpoint while debuggee is running."
+      };
     }
 
     let location = new OriginalLocation(this, line, column);
     return this._getOrCreateBreakpointActor(
       location,
       condition
     ).then((actor) => {
       let response = {
--- a/devtools/server/protocol.js
+++ b/devtools/server/protocol.js
@@ -898,25 +898,25 @@ var Actor = Class({
    * @param [optional] string hint
    *   Optional string to customize the form.
    * @returns A jsonable object.
    */
   form: function(hint) {
     return { actor: this.actorID }
   },
 
-  writeError: function(err) {
-    console.error(err);
-    if (err.stack) {
-      dump(err.stack);
+  writeError: function(error) {
+    console.error(error);
+    if (error.stack) {
+      dump(error.stack);
     }
     this.conn.send({
       from: this.actorID,
-      error: "unknownError",
-      message: err.toString()
+      error: error.error || "unknownError",
+      message: error.message
     });
   },
 
   _queueResponse: function(create) {
     let pending = this._pendingResponse || promise.resolve(null);
     let response = create(pending);
     this._pendingResponse = response;
   }