Throw invalid-data error on unknown attachment link mode in fromJSON()
This commit is contained in:
parent
e9473caa14
commit
4838726b87
1 changed files with 8 additions and 2 deletions
|
@ -2707,7 +2707,7 @@ Zotero.defineProperty(Zotero.Item.prototype, 'attachmentLinkMode', {
|
|||
break;
|
||||
|
||||
default:
|
||||
throw ("Invalid attachment link mode '" + val
|
||||
throw new Error("Invalid attachment link mode '" + val
|
||||
+ "' in Zotero.Item.attachmentLinkMode setter");
|
||||
}
|
||||
|
||||
|
@ -4310,7 +4310,13 @@ Zotero.Item.prototype.fromJSON = function (json, options = {}) {
|
|||
// Attachment metadata
|
||||
//
|
||||
case 'linkMode':
|
||||
this.attachmentLinkMode = Zotero.Attachments["LINK_MODE_" + val.toUpperCase()];
|
||||
let linkMode = Zotero.Attachments["LINK_MODE_" + val.toUpperCase()];
|
||||
if (linkMode === undefined) {
|
||||
let e = new Error(`Unknown attachment link mode '${val}'`);
|
||||
e.name = "ZoteroInvalidDataError";
|
||||
throw e;
|
||||
}
|
||||
this.attachmentLinkMode = linkMode;
|
||||
break;
|
||||
|
||||
case 'contentType':
|
||||
|
|
Loading…
Reference in a new issue