Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

bug fix: if a unloader throws a error then other unloaders are not run. #196

Merged
merged 2 commits into from Jun 29, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/api-utils/lib/unload.js
Expand Up @@ -13,7 +13,11 @@ var when = exports.when = function when(observer) {

var send = exports.send = function send(reason) {
observers.forEach(function (observer) {
observer(reason);
try {
observer(reason);
} catch (e) {
console.exception(e);
}
});
};

Expand Down
6 changes: 5 additions & 1 deletion packages/api-utils/tests/test-unload.js
Expand Up @@ -23,6 +23,7 @@
* Contributor(s):
* Atul Varma <atul@mozilla.com> (Original Author)
* Drew Willcoxon <adw@mozilla.com>
* Erik Vold <erikvvold@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
Expand All @@ -44,7 +45,10 @@ exports.testUnloading = function(test) {
var loader = test.makeSandboxedLoader();
var ul = loader.require("unload");
var unloadCalled = 0;
function unload() { unloadCalled++; }
function unload() {
unloadCalled++;
throw "error";
}
ul.when(unload);

// This should be ignored, as we already registered it
Expand Down