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 draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 09 May 2018 03:44:54 -0700
changeset 793113 263e85494d9e5945adcb5fc551150d1dee28ab11
parent 792871 0cd106a2eb78aa04fd481785257e6f4f9b94707b
push id109280
push userbmo:poirot.alex@gmail.com
push dateWed, 09 May 2018 14:11:35 +0000
reviewersjryans
bugs1458731
milestone62.0a1
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
devtools/shared/protocol.js
--- 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;