commit e5cbfb71a623eb7d5be2a9edafda9a9e166c96cd
parent d67fd9fda2270af17cb6aa6bade501db757725b6
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 5 May 2015 16:14:59 -0400
Throw ZoteroMissingObjectError for missing item errors
And don't log in DataObject.saveData() before rethrowing, since the
calling code will probably take care of it
Diffstat:
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/chrome/content/zotero/xpcom/data/dataObject.js b/chrome/content/zotero/xpcom/data/dataObject.js
@@ -584,7 +584,11 @@ Zotero.DataObject.prototype.save = Zotero.Promise.coroutine(function* (options)
Zotero.debug(e2, 1);
})
.then(function() {
- Zotero.debug(e, 1);
+ // Don't log expected errors
+ if (e.name != 'ZoteroUnknownFieldError'
+ && e.name != 'ZoteroMissingObjectError') {
+ Zotero.debug(e, 1);
+ }
throw e;
})
});
diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js
@@ -1350,8 +1350,10 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
if (isNew) {
if (!parentItemID) {
// TODO: clear caches?
- let msg = parentItemKey + " is not a valid item key";
- throw new Zotero.Error(msg, "MISSING_OBJECT");
+ let msg = "Parent item " + this.libraryID + "/" + parentItemKey + " not found";
+ let e = new Error(msg);
+ e.name = "ZoteroMissingObjectError";
+ throw e;
}
let newParentItemNotifierData = {};
@@ -1372,8 +1374,10 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
if (parentItemKey) {
if (!parentItemID) {
// TODO: clear caches
- let msg = "Cannot set source to invalid item " + parentItemKey;
- throw new Zotero.Error(msg, "MISSING_OBJECT");
+ let msg = "Parent item " + this.libraryID + "/" + parentItemKey + " not found";
+ let e = new Error(msg);
+ e.name = "ZoteroMissingObjectError";
+ throw e;
}
let newParentItemNotifierData = {};