node.js - Bluebird - how to propagate errors in nested promise -


promisea().then(function(){     promiseb().catch(function (e) {         throw e;     }) }).catch(function (e) {     // want exceptions thrown in nested promise chain end here. }) 

how exceptions nested promises bubble parent promise?

use return keyword,

your code can simplified as:

promisea().then(function(){     return promiseb(); }).catch(function (e) {     // want exceptions thrown in nested promise chain end here. }) 

edit:

not sure if right way, if promise cancellation involved , want bubble error flow, can wrap promise in custom promise never resolves throws error( if happens):

promisea().then(function(){     var mypromise = promiseb().then...;     return new promise(function(resolve, reject){       mypromise.catch(reject)     }) }).catch(function (e) {     // want exceptions thrown in nested promise chain end here. }) 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -