From 1855b5e1f9a8e6b31e96c57a24dd1398dcf4dffe Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 4 Feb 2016 03:50:48 -0500 Subject: [PATCH] A couple better error messages --- chrome/content/zotero/xpcom/data/dataObject.js | 4 ++++ chrome/content/zotero/xpcom/data/item.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/data/dataObject.js b/chrome/content/zotero/xpcom/data/dataObject.js index 477e5e47b..183544f58 100644 --- a/chrome/content/zotero/xpcom/data/dataObject.js +++ b/chrome/content/zotero/xpcom/data/dataObject.js @@ -1227,6 +1227,10 @@ Zotero.DataObject.prototype.toResponseJSON = Zotero.Promise.coroutine(function* Zotero.DataObject.prototype._preToJSON = function (options) { + if (!this._id) { + throw new Error(`${this._ObjectType} must be saved before running toJSON()`); + } + var env = { options }; env.mode = options.mode || 'new'; if (env.mode == 'patch') { diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 2af86d48b..46f85eb28 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -4000,7 +4000,7 @@ Zotero.Item.prototype.loadItemData = Zotero.Promise.coroutine(function* (reload) Zotero.debug("Loading item data for item " + this.libraryKey); if (!this.id) { - throw ('ItemID not set for object before attempting to load data'); + throw new Error('ItemID not set for object before attempting to load data'); } if (!this.isNote()) {