From 910f698ea20be42724f8509dbc7f0cdedbc5667f Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sun, 15 Jul 2012 04:14:24 -0400 Subject: [PATCH] Alter semantics of Zotero.Exception.Alert() so that toString() returns the cause if there is one --- chrome/content/zotero/xpcom/error.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/xpcom/error.js b/chrome/content/zotero/xpcom/error.js index 99f89a4e5..638c4ada4 100644 --- a/chrome/content/zotero/xpcom/error.js +++ b/chrome/content/zotero/xpcom/error.js @@ -98,10 +98,7 @@ Zotero.Exception.Alert.prototype = { } }, - /** - * Gets the error string - */ - "toString":function() { + get message() { try { return Zotero.getString(this.name, this.params); } catch(e) { @@ -109,6 +106,13 @@ Zotero.Exception.Alert.prototype = { } }, + /** + * Gets the error string + */ + "toString":function() { + return this.cause.toString() || this.message; + }, + /** * Presents the error in a dialog * @param {DOMWindow} window The window to which the error should be attached @@ -116,9 +120,9 @@ Zotero.Exception.Alert.prototype = { "present":function(window) { Components.utils.import("resource://gre/modules/Services.jsm"); try { - Services.prompt.alert(window || null, this.title, this.toString()); - }catch(e) { - Zotero.debug(e); + Services.prompt.alert(window || null, this.title, this.message); + } catch(e) { + Zotero.debug(e); } },