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
This commit is contained in:
parent
d67fd9fda2
commit
e5cbfb71a6
2 changed files with 13 additions and 5 deletions
|
@ -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;
|
||||
})
|
||||
});
|
||||
|
|
|
@ -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 = {};
|
||||
|
|
Loading…
Reference in a new issue