Bug 1439177: Throw ExtensionError rather than Error when appropriate. r?zombie draft
authorKris Maglione <maglione.k@gmail.com>
Sat, 17 Feb 2018 19:04:58 -0800
changeset 756790 a0f34937e2a0b6a7647731f27a2882deab94d7b1
parent 756750 2a0bd14b1bfd40a6fb18e21f7ecaae45d30fed31
child 756791 c7004cdf4b13af0ce40e974ee30c48ef00d7093b
push id99547
push usermaglione.k@gmail.com
push dateSun, 18 Feb 2018 03:05:46 +0000
reviewerszombie
bugs1439177
milestone60.0a1
Bug 1439177: Throw ExtensionError rather than Error when appropriate. r?zombie MozReview-Commit-ID: 6GGwtFl1lUy
browser/components/extensions/ext-menus.js
--- a/browser/components/extensions/ext-menus.js
+++ b/browser/components/extensions/ext-menus.js
@@ -559,21 +559,21 @@ MenuItem.prototype = {
       checked: false,
       contexts: ["all"],
       enabled: true,
     });
   },
 
   set id(id) {
     if (this.hasOwnProperty("_id")) {
-      throw new Error("Id of a MenuItem cannot be changed");
+      throw new ExtensionError("ID of a MenuItem cannot be changed");
     }
     let isIdUsed = gMenuMap.get(this.extension).has(id);
     if (isIdUsed) {
-      throw new Error("Id already exists");
+      throw new ExtensionError("ID already exists");
     }
     this._id = id;
   },
 
   get id() {
     return this._id;
   },
 
@@ -590,17 +590,17 @@ MenuItem.prototype = {
   },
 
   ensureValidParentId(parentId) {
     if (parentId === undefined) {
       return;
     }
     let menuMap = gMenuMap.get(this.extension);
     if (!menuMap.has(parentId)) {
-      throw new Error("Could not find any MenuItem with id: " + parentId);
+      throw new ExtensionError(`Could not find any MenuItem with id: ${parentId}`);
     }
     for (let item = menuMap.get(parentId); item; item = item.parent) {
       if (item === this) {
         throw new ExtensionError("MenuItem cannot be an ancestor (or self) of its new parent.");
       }
     }
   },