I like the idea of chaining the promises in my code so that it looks nice, pretty nice and easier to read. After several months following this pattern, I have a situation where I need to break the chain promise flow, like stopping the flow. See the below snippet code:
From the above code, I am expecting the code to stop chain and move on to the .catch handler, but is not. I learned the code will continue the flow as I return with no value at line 9.
So, here is the way to break the promise chains, instead of returning with no value, I throw an Error to stop the flow:
Oh, yeah I use Bluebird to working with Promise…