title: Bluebird Promise Cancellation
body: <p>Say I have the following Promise chain:</p>
  
  <pre><code>var parentPromise = Promise.resolve()
    .then(function () {
      var condition = false;
      if (condition) {
        return parentPromise.cancel('valid reason');
      } else {
        return Promise.resolve()
          .then(function () {
            var someOtherCondition = true;
            if (someOtherCondition) {
              console.log('inner cancellation');
              return parentPromise.cancel('invalid reason');
            }
          });
      }
    })
    .catch(Promise.CancellationError, function (err) {
      console.log('throwing');
      if (err.message !== 'valid reason') {
        throw err;
      }
    })
    .cancellable();
  </code></pre>
  
  <p>The above never enters the <code>catch</code>.</p>
  
  <p>If we swap <code>condition</code> to <code>true</code>, the inner cancellation is never hit, but the <code>catch</code> is still not triggered.</p>
  
  <p>removing the <code>.cancellable</code> at the end , and replacing all instances of <code>parentPromise.cancel()</code> with explicit <code>throw new Promise.CancellationError()</code> "fixes" the problem. What I don't understand is why?</p>
  
  <p>Why was the original approach not working?</p>
  
  <p>I am using bluebird 2.3.11.</p>