display errors in dialog (for MacWord and maybe work for WinWord, although I have yet to test; OOo users get a separate window)

This commit is contained in:
Simon Kornblith 2009-09-19 04:17:40 +00:00
parent 49fbfb8798
commit 2e93767c81

View File

@ -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;