Bug 1449162 - 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 788348 403eba65d48fb13f8db7fb661e7cb9bf29f81d0c
parent 788347 3791a9a18c6b69cc471dbcd8cb9c4a77faefc067
push id107968
push userbmo:poirot.alex@gmail.com
push dateThu, 26 Apr 2018 11:55:56 +0000
reviewersjryans
bugs1449162
milestone61.0a1
Bug 1449162 - 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
@@ -1129,16 +1129,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}' specify 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;
           }