better handling of invalid JSON objects

This commit is contained in:
Simon Kornblith 2008-09-11 20:53:15 +00:00
parent 7d9493827e
commit f6b1d6e56e

View File

@ -131,7 +131,12 @@ Zotero.Translator = function(file) {
if(!m) { if(!m) {
this.logError("Invalid or missing translator metadata JSON object"); this.logError("Invalid or missing translator metadata JSON object");
} else { } else {
try {
var info = Zotero.JSON.unserialize(m[0]); var info = Zotero.JSON.unserialize(m[0]);
} catch(e) {
this.logError("Invalid or missing translator metadata JSON object");
}
if(info) {
var haveMetadata = true; var haveMetadata = true;
// make sure we have all the properties // make sure we have all the properties
for each(var property in ["translatorID", "translatorType", "label", "target", "lastUpdated"]) { for each(var property in ["translatorID", "translatorType", "label", "target", "lastUpdated"]) {
@ -163,6 +168,7 @@ Zotero.Translator = function(file) {
} }
} }
} }
}
fStream.close(); fStream.close();
} }