I noticed that when function uploadLogs()
is rejected, the expected rejection bubbling up to be handled by function reject(reason)
does not occur. Why is this happening?
In the code below, a rejection handler for function uploadLogs()
successfully handles the rejection:
return EventCollector.persist().then(function persistResolve() {
return EventCollector.uploadLogs().then(function uploadLogsResolve() {
return closeApp();
}, function rejectionHandler() {
console.log("this rejection handler manages the event")
});
}, function reject(reason) {
return closeApp();
});
However, if I remove the rejection handler and expect the rejection to bubble up and be handled by the rejection handler of persist()
, it surprisingly doesn't.
return EventCollector.persist().then(function persistResolve() {
return EventCollector.uploadLogs().then(function uploadLogsResolve() {
return closeApp();
});
}, function reject(reason) {
console.log("rejection is not handled when uploadLogs() fails");
return closeApp();
});
Shouldn't promise chaining and rejection bubbling operate in this manner as intended?