commit 7984bb195c7a567043dde3861eb7c4bab6c70a47
parent c20863e8fa5e634df4e96f9c1adbb58ec81a9c92
Author: Simon Kornblith <simon@simonster.com>
Date: Thu, 10 Feb 2011 01:53:15 +0000
better startup error handling
Diffstat:
3 files changed, 49 insertions(+), 32 deletions(-)
diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js
@@ -164,6 +164,11 @@ var ZoteroOverlay = new function()
return;
}
+ if(!Zotero || !Zotero.initialized) {
+ ZoteroPane.displayStartupError();
+ return;
+ }
+
var zoteroPane = document.getElementById('zotero-pane-stack');
var zoteroSplitter = document.getElementById('zotero-splitter');
var isHidden = zoteroPane.getAttribute('hidden') == 'true';
diff --git a/chrome/content/zotero/standalone.js b/chrome/content/zotero/standalone.js
@@ -29,9 +29,12 @@
var ZoteroStandalone = new function()
{
this.onLoad = function() {
+ if(!Zotero || !Zotero.initialized) {
+ ZoteroPane.displayStartupError();
+ window.close();
+ }
ZoteroPane.init();
- var success = ZoteroPane.makeVisible();
- if(!success) window.close();
+ ZoteroPane.makeVisible();
}
this.onUnload = function() {
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
@@ -340,36 +340,7 @@ var ZoteroPane = new function()
// If Zotero could not be initialized, display an error message and return
if(!Zotero || !Zotero.initialized) {
- if (Zotero) {
- var errMsg = Zotero.startupError;
- var errFunc = Zotero.startupErrorHandler;
- }
-
- if (!errMsg) {
- // Get the stringbundle manually
- var src = 'chrome://zotero/locale/zotero.properties';
- var localeService = Components.classes['@mozilla.org/intl/nslocaleservice;1'].
- getService(Components.interfaces.nsILocaleService);
- var appLocale = localeService.getApplicationLocale();
- var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
- .getService(Components.interfaces.nsIStringBundleService);
- var stringBundle = stringBundleService.createBundle(src, appLocale);
-
- var errMsg = stringBundle.GetStringFromName('startupError');
- }
-
- if (errFunc) {
- errFunc();
- }
- else {
- // TODO: Add a better error page/window here with reporting
- // instructions
- // window.loadURI('chrome://zotero/content/error.xul');
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
- ps.alert(null, "", errMsg);
- }
-
+ this.displayStartupError();
return false;
}
@@ -3389,6 +3360,44 @@ var ZoteroPane = new function()
Zotero.debug(msg, 1);
}
+ this.displayStartupError = function(asPaneMessage) {
+ if(!Zotero || !Zotero.initialized) {
+ if (Zotero) {
+ var errMsg = Zotero.startupError;
+ var errFunc = Zotero.startupErrorHandler;
+ }
+
+ if (!errMsg) {
+ // Get the stringbundle manually
+ var src = 'chrome://zotero/locale/zotero.properties';
+ var localeService = Components.classes['@mozilla.org/intl/nslocaleservice;1'].
+ getService(Components.interfaces.nsILocaleService);
+ var appLocale = localeService.getApplicationLocale();
+ var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
+ .getService(Components.interfaces.nsIStringBundleService);
+ var stringBundle = stringBundleService.createBundle(src, appLocale);
+
+ var errMsg = stringBundle.GetStringFromName('startupError');
+ }
+
+ if (errFunc) {
+ errFunc();
+ }
+ else {
+ // TODO: Add a better error page/window here with reporting
+ // instructions
+ // window.loadURI('chrome://zotero/content/error.xul');
+ //if(asPaneMessage) {
+ // ZoteroPane.setItemsPaneMessage(errMsg, true);
+ //} else {
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+ ps.alert(null, "", errMsg);
+ //}
+ }
+ }
+ }
+
/**
* Toggles Zotero-as-a-tab by passing off the request to the ZoteroOverlay object associated
* with the present window