Report deferred exceptions via callback
This commit is contained in:
parent
fa570a9514
commit
21c0067462
|
@ -2072,7 +2072,20 @@ DataSource.prototype.ready = function (obj, args) {
|
|||
if (timeoutHandle) {
|
||||
clearTimeout(timeoutHandle);
|
||||
}
|
||||
method.apply(obj, [].slice.call(args));
|
||||
var params = [].slice.call(args);
|
||||
try {
|
||||
method.apply(obj, params);
|
||||
} catch (err) {
|
||||
// Catch the exception and report it via callback
|
||||
var cb = params.pop();
|
||||
if (typeof cb === 'function') {
|
||||
process.nextTick(function() {
|
||||
cb(err);
|
||||
});
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
onError = function (err) {
|
||||
// Remove the connected listener
|
||||
|
@ -2083,7 +2096,9 @@ DataSource.prototype.ready = function (obj, args) {
|
|||
var params = [].slice.call(args);
|
||||
var cb = params.pop();
|
||||
if (typeof cb === 'function') {
|
||||
process.nextTick(function() {
|
||||
cb(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
this.once('connected', onConnected);
|
||||
|
|
Loading…
Reference in New Issue