commit 910f698ea20be42724f8509dbc7f0cdedbc5667f
parent de2d1669fea84116028f40c728f84d655ac33fdd
Author: Simon Kornblith <simon@simonster.com>
Date: Sun, 15 Jul 2012 04:14:24 -0400
Alter semantics of Zotero.Exception.Alert() so that toString() returns the cause if there is one
Diffstat:
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git 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) {
@@ -110,15 +107,22 @@ 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
*/
"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);
}
},