Bug 1460229 - Throw an explicit error message when a method specified in a spec is missing in the actor. r=jryans draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 28 Mar 2018 01:08:06 -0700
changeset 795597 c422438e6767e4b165a05b8e0a712ab8997e73b4
parent 795256 cf3ee14023483cbbb57129479537c713e22c1980
push id110031
push userbmo:poirot.alex@gmail.com
push dateWed, 16 May 2018 09:35:55 +0000
reviewersjryans
bugs1460229
milestone62.0a1
Bug 1460229 - Throw an explicit error message when a method specified in a spec is missing in the actor. r=jryans MozReview-Commit-ID: JdsCMh93xZE
devtools/shared/protocol.js
--- a/devtools/shared/protocol.js
+++ b/devtools/shared/protocol.js
@@ -1146,16 +1146,20 @@ var generateRequestHandlers = function(a
         let args;
         try {
           args = spec.request.read(packet, this);
         } catch (ex) {
           console.error("Error reading request: " + packet.type);
           throw ex;
         }
 
+        if (!this[spec.name]) {
+          throw new Error(`Spec for '${actorProto.typeName}' specifies a '${spec.name}'` +
+                          ` method that isn't implemented by the actor`);
+        }
         let ret = this[spec.name].apply(this, args);
 
         let sendReturn = (retToSend) => {
           if (spec.oneway) {
             // No need to send a response.
             return;
           }