diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 82fdc6ef1d..f00880c438 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -1049,9 +1049,26 @@ Zotero.Integration.Document.prototype._getSession = Zotero.Promise.coroutine(fun if (/^https?:\/\/(www\.)?(zotero\.org|citationstyles\.org)/.test(data.style.styleID) || me._doc.displayAlert(displayError, DIALOG_ICON_WARNING, DIALOG_BUTTONS_YES_NO)) { - yield Zotero.Styles.install({url: data.style.styleID}, data.style.styleID, true); - yield this._session.setData(data, true); - return Zotero.Promise.resolve(this._session); + let installed = false; + try { + yield Zotero.Styles.install( + {url: data.style.styleID}, data.style.styleID, true + ); + installed = true; + } + catch (e) { + me._doc.displayAlert( + Zotero.getString( + 'integration.error.styleNotFound', data.style.styleID + ), + DIALOG_ICON_WARNING, + DIALOG_BUTTONS_OK + ); + } + if (installed) { + yield this._session.setData(data, true); + return Zotero.Promise.resolve(this._session); + } } } return this._session.setDocPrefs(this._doc, this._app.primaryFieldType, diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 8fa233ef56..36a2d4584d 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -827,6 +827,7 @@ integration.error.deletePipe = The pipe that Zotero uses to communicate with t integration.error.invalidStyle = The style you have selected does not appear to be valid. If you have created this style yourself, please ensure that it passes validation as described at https://github.com/citation-style-language/styles/wiki/Validation. Alternatively, try selecting another style. integration.error.fieldTypeMismatch = Zotero cannot update this document because it was created by a different word processing application with an incompatible field encoding. In order to make a document compatible with both Word and LibreOffice, open the document in the word processor with which it was originally created and switch the field type to Bookmarks in the Zotero Document Preferences. integration.error.styleMissing = The citation style used in this document is missing. Would you like to install it from %S? +integration.error.styleNotFound = The citation style %S could not be found. integration.replace = Replace this Zotero field? integration.missingItem.single = The highlighted citation no longer exists in your Zotero database. Do you want to select a substitute item?