www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit f008342dd81816ff436abb13fabd474415916105
parent bb563570f34a1d8e3df436cd710785f298ac49f9
Author: Simon Kornblith <simon@simonster.com>
Date:   Mon,  1 Apr 2013 13:19:29 -0400

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

Diffstat:
Mchrome/content/zotero/xpcom/cite.js | 37++++++++++++++++++-------------------
1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js @@ -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