commit f5af708995964f076af21c27a72064b148c98f1e
parent ca8c7ba5841a86a75def374c23daaadf2273c65d
Author: Simon Kornblith <simon@simonster.com>
Date: Sun, 3 Jul 2011 08:28:30 +0000
- Eliminate some error messages in translate.js
- Zotero.ItemFields.isValidForType() should not throw on error
Diffstat:
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/chrome/content/zotero/xpcom/connector/cachedTypes.js b/chrome/content/zotero/xpcom/connector/cachedTypes.js
@@ -115,7 +115,7 @@ Zotero.ItemFields = new function() {
this.isValidForType = function(fieldIdOrName, typeIdOrName) {
// mimics itemFields.js
if(!Zotero.Connector_Types["fields"][fieldIdOrName]
- || !Zotero.Connector_Types["itemTypes"][typeIdOrName]) throw "Invalid field or type ID";
+ || !Zotero.Connector_Types["itemTypes"][typeIdOrName]) return false;
return Zotero.Connector_Types["itemTypes"][typeIdOrName].fields.indexOf(
Zotero.Connector_Types["fields"][fieldIdOrName].id) !== -1;
@@ -123,7 +123,7 @@ Zotero.ItemFields = new function() {
this.getFieldIDFromTypeAndBase = function(itemType, baseField) {
if(!Zotero.Connector_Types["fields"][baseField]
- || !Zotero.Connector_Types["itemTypes"][itemType]) throw "Invalid field or type ID";
+ || !Zotero.Connector_Types["itemTypes"][itemType]) throw new Error("Invalid field or type ID");
// get as ID
baseField = Zotero.Connector_Types["fields"][baseField].id;
diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js
@@ -465,6 +465,7 @@ Zotero.Translate.Sandbox = {
}
// create short title
+ Zotero.debug("item type is "+item.itemType);
if(item.shortTitle === undefined && Zotero.Utilities.fieldIsValidForType("shortTitle", item.itemType)) {
// only set if changes have been made
var setShortTitle = false;
@@ -793,7 +794,7 @@ Zotero.Translate.Base.prototype = {
*/
"getTranslators":function(getAllTranslators) {
// do not allow simultaneous instances of getTranslators
- if(this._currentState == "detect") throw new Error("getTranslators: detection is already running");
+ if(this._currentState === "detect") throw new Error("getTranslators: detection is already running");
this._currentState = "detect";
this._getAllTranslators = getAllTranslators;
this._getTranslatorsGetPotentialTranslators();
@@ -1426,6 +1427,8 @@ Zotero.Translate.Import.prototype._getTranslatorsGetPotentialTranslators = funct
*/
Zotero.Translate.Import.prototype.getTranslators = function() {
if(!this._string && !this.location) {
+ if(this._currentState === "detect") throw new Error("getTranslators: detection is already running");
+ this._currentState = "detect";
this._foundTranslators = Zotero.Translators.getAllForType(this.type);
this._potentialTranslators = [];
this.complete(true);
@@ -1562,6 +1565,8 @@ Zotero.Translate.Export.prototype.complete = Zotero.Translate.Import.prototype.c
* Overload {@link Zotero.Translate.Base#getTranslators} to return all translators immediately
*/
Zotero.Translate.Export.prototype.getTranslators = function() {
+ if(this._currentState === "detect") throw new Error("getTranslators: detection is already running");
+ this._currentState = "detect";
this._foundTranslators = Zotero.Translators.getAllForType(this.type);
this._potentialTranslators = [];
this.complete(true);