You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functiondoLotsOfStuff(params,cb){doStuff(params.foo,params.bar,function(err1,result){doMoreStuff(function(err2,result){if(err2){cb(err2)return;}doEvenMoreStuff(params.baz,function(err3,result){// callback pyramid of doom});});});}
Promises Pyramid of Doom
functiondoLotsOfStuff(params){returndoStuff(params.foo,params.bar).then(function(result){returndoMoreStuff().then(function(result){returndoEvenMoreStuff(params.baz).then(function(result){// promises pyramid of doomreturnresult;});}).catch(function(err){if('FIX_ME'===err.code){return{fixed: true};}throwerr;});});}
try/catch Pyramid of Doom
asyncfunctiondoLotsOfStuff(params){try{varresult=awaitdoStuff(params.foo,params.bar);try{varresult=awaitdoMoreStuff();try{varresult=awaitdoEvenMoreStuff(params.baz).then(function(result){// try/catch pyramid of doomreturnresult;}catch(e){throwerr;}}catch(e){if('FIX_ME'===err.code){return{fixed: true};}throwerr;}}catch(e){throwerr;}}