mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1010531 - Prevent async callback from throwing when a callback is made with an error. r=rnewman
This commit is contained in:
parent
cc68451c4d
commit
3da402253d
@ -63,6 +63,12 @@ this.Async = {
|
||||
/**
|
||||
* Create a sync callback that remembers state, in particular whether it has
|
||||
* been called.
|
||||
* The returned callback can be called directly passing an optional arg which
|
||||
* will be returned by waitForSyncCallback(). The callback also has a
|
||||
* .throw() method, which takes an error object and will cause
|
||||
* waitForSyncCallback to fail with the error object thrown as an exception
|
||||
* (but note that the .throw method *does not* itself throw - it just causes
|
||||
* the wait function to throw).
|
||||
*/
|
||||
makeSyncCallback: function makeSyncCallback() {
|
||||
// The main callback remembers the value it was passed, and that it got data.
|
||||
@ -79,9 +85,6 @@ this.Async = {
|
||||
onComplete.throw = function onComplete_throw(data) {
|
||||
onComplete.state = CB_FAIL;
|
||||
onComplete.value = data;
|
||||
|
||||
// Cause the caller to get an exception and stop execution.
|
||||
throw data;
|
||||
};
|
||||
|
||||
return onComplete;
|
||||
@ -136,7 +139,8 @@ this.Async = {
|
||||
function callback(error, ret) {
|
||||
if (error)
|
||||
cb.throw(error);
|
||||
cb(ret);
|
||||
else
|
||||
cb(ret);
|
||||
}
|
||||
callback.wait = function() Async.waitForSyncCallback(cb);
|
||||
return callback;
|
||||
|
@ -380,7 +380,8 @@ Resource.prototype = {
|
||||
function callback(error, ret) {
|
||||
if (error)
|
||||
cb.throw(error);
|
||||
cb(ret);
|
||||
else
|
||||
cb(ret);
|
||||
}
|
||||
|
||||
// The channel listener might get a failure code
|
||||
|
Loading…
Reference in New Issue
Block a user