Skip to content

Commit

Permalink
Handle errors possibly thrown from .showAlertNotification().
Browse files Browse the repository at this point in the history
  • Loading branch information
arantius committed Nov 16, 2010
1 parent ebd2518 commit 4f0f4cb
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions modules/GM_notification.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@

// JSM exported symbols
var EXPORTED_SYMBOLS = ["GM_notification"];

const alertsServ = Components.classes["@mozilla.org/alerts-service;1"]
.getService(Components.interfaces.nsIAlertsService);

function GM_notification(aMsg, aTitle) {
alertsServ.showAlertNotification(
"chrome://greasemonkey/skin/icon_medium.png",
aTitle || "Greasemonkey",
aMsg+"",
false,
"",
null);
var title = aTitle ? "" + aTitle : "Greasemonkey";
var message = aMsg ? "" + aMsg : "";
try {
alertsServ.showAlertNotification(
"chrome://greasemonkey/skin/icon_medium.png",
title, message, false, "", null);
} catch (e) {
// In case e.g. Growl is not installed on a Mac.
alert(title + "\n" + message);
}
};

0 comments on commit 4f0f4cb

Please sign in to comment.