Alter semantics of Zotero.Exception.Alert() so that toString() returns the cause if there is one
This commit is contained in:
parent
de2d1669fe
commit
910f698ea2
|
@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user