Throw error in Item::fromJSON() if itemType not provided and not set

This commit is contained in:
Dan Stillman 2015-06-16 20:35:31 -04:00
parent e45aabd03c
commit 79733c75f1

View file

@ -3802,6 +3802,10 @@ Zotero.Item.prototype.fromJSON = Zotero.Promise.coroutine(function* (json) {
yield this.loadAllData(); yield this.loadAllData();
} }
if (!json.itemType && !this._itemTypeID) {
throw new Error("itemType property not provided");
}
let itemTypeID = Zotero.ItemTypes.getID(json.itemType); let itemTypeID = Zotero.ItemTypes.getID(json.itemType);
this.setType(itemTypeID); this.setType(itemTypeID);