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
|
@ -584,7 +584,11 @@ Zotero.DataObject.prototype.save = Zotero.Promise.coroutine(function* (options)
|
||||||
Zotero.debug(e2, 1);
|
Zotero.debug(e2, 1);
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
Zotero.debug(e, 1);
|
// Don't log expected errors
|
||||||
|
if (e.name != 'ZoteroUnknownFieldError'
|
||||||
|
&& e.name != 'ZoteroMissingObjectError') {
|
||||||
|
Zotero.debug(e, 1);
|
||||||
|
}
|
||||||
throw e;
|
throw e;
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -1350,8 +1350,10 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
if (!parentItemID) {
|
if (!parentItemID) {
|
||||||
// TODO: clear caches?
|
// TODO: clear caches?
|
||||||
let msg = parentItemKey + " is not a valid item key";
|
let msg = "Parent item " + this.libraryID + "/" + parentItemKey + " not found";
|
||||||
throw new Zotero.Error(msg, "MISSING_OBJECT");
|
let e = new Error(msg);
|
||||||
|
e.name = "ZoteroMissingObjectError";
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
let newParentItemNotifierData = {};
|
let newParentItemNotifierData = {};
|
||||||
|
@ -1372,8 +1374,10 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
|
||||||
if (parentItemKey) {
|
if (parentItemKey) {
|
||||||
if (!parentItemID) {
|
if (!parentItemID) {
|
||||||
// TODO: clear caches
|
// TODO: clear caches
|
||||||
let msg = "Cannot set source to invalid item " + parentItemKey;
|
let msg = "Parent item " + this.libraryID + "/" + parentItemKey + " not found";
|
||||||
throw new Zotero.Error(msg, "MISSING_OBJECT");
|
let e = new Error(msg);
|
||||||
|
e.name = "ZoteroMissingObjectError";
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
let newParentItemNotifierData = {};
|
let newParentItemNotifierData = {};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user