Bug 1439177: Throw ExtensionError rather than Error when appropriate. r?zombie
MozReview-Commit-ID: 6GGwtFl1lUy
--- 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.");
}
}
},