Closed serratedserenade closed 5 years ago
A minor suggestion, but I would instead do:
if (resolvedFunction.then) {
resolvedFunction.then(
function() {},
cb
);
}
This way this will work for bluebird promises or other "thenables", even if they don't inherit from Promise
.
Possibly, you might also want to do:
if (resolvedFunction.then) {
resolvedFunction.then(
function() {cb()},
cb
);
}
That way the callback gets called either way, even if there's no error.
Tested: node v8.1.2
Thought it would be appropriate that if the evoked controllerFunction is an async function, have it handle the callback when an error is thrown by having the callback within its catch method instead of giving an unhandled promise rejection error.
Example:
Fixed: