Show a better error when citeproc-js requests an non-existent item

This commit is contained in:
Simon Kornblith 2013-04-01 13:19:29 -04:00
parent bb563570f3
commit f008342dd8

View file

@ -471,31 +471,30 @@ Zotero.Cite.System.prototype = {
*/
"retrieveItem":function retrieveItem(item) {
var zoteroItem, slashIndex;
if(item instanceof Zotero.Item) {
if(typeof item === "object" && item !== null && item instanceof Zotero.Item) {
//if(this._cache[item.id]) return this._cache[item.id];
zoteroItem = item;
} else {
var type = typeof item;
if(type === "string" && (slashIndex = item.indexOf("/")) !== -1) {
// is an embedded item
var sessionID = item.substr(0, slashIndex);
var session = Zotero.Integration.sessions[sessionID]
if(session) {
var embeddedCitation = session.embeddedItems[item.substr(slashIndex+1)];
if(embeddedCitation) {
embeddedCitation.id = item;
return embeddedCitation;
}
} else if(typeof item === "string" && (slashIndex = item.indexOf("/")) !== -1) {
// is an embedded item
var sessionID = item.substr(0, slashIndex);
var session = Zotero.Integration.sessions[sessionID]
if(session) {
var embeddedCitation = session.embeddedItems[item.substr(slashIndex+1)];
if(embeddedCitation) {
embeddedCitation.id = item;
return embeddedCitation;
}
} else {
// is an item ID
//if(this._cache[item]) return this._cache[item];
zoteroItem = Zotero.Items.get(item);
}
} else {
// is an item ID
//if(this._cache[item]) return this._cache[item];
try {
zoteroItem = Zotero.Items.get(item);
} catch(e) {}
}
if(!zoteroItem) {
throw "Zotero.Cite.getCSLItem called to wrap a non-item "+item;
throw "Zotero.Cite.System.retrieveItem called on non-item "+item;
}
// don't return URL or accessed information for journal articles if a