commit 2e93767c81dfb9938b2af9ea05973d3060751d68
parent 49fbfb8798eaf2af8fcadca0e5d33c2f7a5a6034
Author: Simon Kornblith <simon@simonster.com>
Date: Sat, 19 Sep 2009 04:17:40 +0000
display errors in dialog (for MacWord and maybe work for WinWord, although I have yet to test; OOo users get a separate window)
Diffstat:
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js
@@ -156,7 +156,33 @@ Zotero.Integration = new function() {
Components.interfaces.zoteroIntegrationDocument.DIALOG_ICON_STOP,
Components.interfaces.zoteroIntegrationDocument.DIALOG_BUTTONS_OK);
} else {
- integration._doc.displayAlert(Zotero.getString("integration.error.generic"),
+ // check to see whether there's a pyxpcom error in the console, since it doesn't
+ // get thrown directly
+ var throwErr = true;
+ var message = "";
+
+ var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
+ .getService(Components.interfaces.nsIConsoleService);
+
+ var messages = {};
+ consoleService.getMessageArray(messages, {});
+ messages = messages.value;
+ if(messages && messages.length) {
+ var lastMessage = messages[messages.length-1];
+ try {
+ var error = lastMessage.QueryInterface(Components.interfaces.nsIScriptError);
+ } catch(e2) {
+ if(lastMessage.message && lastMessage.message.substr(0, 12) == "ERROR:xpcom:") {
+ // print just the last line of the message, but re-throw the rest
+ message = lastMessage.message.substr(0, lastMessage.message.length-1);
+ message = "\n"+message.substr(message.lastIndexOf("\n"))
+ }
+ }
+ }
+
+ if(!message && typeof(e) == "object" && e.message) message = "\n"+e.message;
+
+ integration._doc.displayAlert(Zotero.getString("integration.error.generic")+message,
Components.interfaces.zoteroIntegrationDocument.DIALOG_ICON_STOP,
Components.interfaces.zoteroIntegrationDocument.DIALOG_BUTTONS_OK);
throw e;