Better logging for Extra migration

This commit is contained in:
Dan Stillman 2020-03-17 11:57:18 -04:00
parent d8d07362ba
commit c4aad9a041

View file

@ -4625,8 +4625,28 @@ Zotero.Item.prototype.migrateExtraFields = function () {
return false;
}
var originalExtra = this.getField('extra');
var log = function () {
Zotero.debug("Original Extra:\n\n" + originalExtra);
if (itemType) {
Zotero.debug("Item Type: " + itemType);
}
if (fields.size) {
Zotero.debug("Fields:\n\n" + Array.from(fields.entries()).map(x => `${x[0]}: ${x[1]}`).join("\n"));
}
if (creators.length) {
Zotero.debug("Creators:");
Zotero.debug(creators);
}
if (extra) {
Zotero.debug("Remaining Extra:\n\n" + extra);
}
};
try {
var { itemType, fields, creators, extra } = Zotero.Utilities.Internal.extractExtraFields(
this.getField('extra'), this
originalExtra, this
);
if (itemType) {
this.setType(Zotero.ItemTypes.getID(itemType));
@ -4641,19 +4661,15 @@ Zotero.Item.prototype.migrateExtraFields = function () {
if (!this.hasChanged()) {
return false;
}
}
catch (e) {
Zotero.logError("Error migrating Extra fields for item " + this.libraryKey);
log();
throw e;
}
Zotero.debug("Migrating Extra fields for item " + this.libraryKey);
if (itemType) {
Zotero.debug("Item Type: " + itemType);
}
if (fields.size) {
Zotero.debug("Fields:\n\n" + Array.from(fields.entries()).map(x => `${x[0]}: ${x[1]}`).join("\n"));
}
if (creators.length) {
Zotero.debug("Creators:");
Zotero.debug(creators);
}
Zotero.debug("Remaining Extra:\n\n" + extra);
log();
return true;
}