Bug 1439177: Throw ExtensionError rather than Error when appropriate. r=zombie

MozReview-Commit-ID: 6GGwtFl1lUy

--HG--
extra : rebase_source : 02e208ff7025174cb36dc4c9c70b17ce9986b9d6
This commit is contained in:
Kris Maglione 2018-02-17 19:04:58 -08:00
parent b1312404c0
commit ed54af49b2

View File

@ -564,11 +564,11 @@ MenuItem.prototype = {
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: ${id}`);
}
this._id = id;
},
@ -595,7 +595,7 @@ MenuItem.prototype = {
}
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) {