title: Skipping promise chain after handling error
body: <p>Using the <a href="https://github.com/kriskowal/q">https://github.com/kriskowal/q</a> library, I'm wondering if it's possible to do something like this:</p>
  
  <pre><code>// Module A
  
  function moduleA_exportedFunction() {
    return promiseReturningService().then(function(serviceResults) {
      if (serviceResults.areGood) {
        // We can continue with the rest of the promise chain
      }
      else {
        performVerySpecificErrorHandling();
        // We want to skip the rest of the promise chain
      }
    });
  }
  
  // Module B
  
  moduleA_exportedFunction()
    .then(moduleB_function)
    .then(moduleB_anotherFunction)
    .fail(function(reason) {
      // Handle the reason in a general way which is ok for module B functions
    })
    .done()
  ;
  </code></pre>
  
  <p>Basically if the service results are bad, I'd like to handle the failure in module A, using logic that is specific to the internals of module A, but still skip the remaining module B functions in the promise chain.</p>
  
  <p>The obvious solution for skipping module B functions is to throw an error/reason from module A. However, then I would need to handle that in module B. And ideally I'd like to do it without needing any extra code in module B for that.</p>
  
  <p>Which may very well be impossible :) Or against some design principles of Q.</p>
  
  <p>In which case, what kind of alternatives would you suggest?</p>
  
  <p>I have two approaches in mind, but both have their disadvantages:</p>
  
  <ol>
  <li><p>Throw a specific error from module A and add specific handling code to module B:</p>
  
  <pre><code>.fail(function(reason) {
    if (reason is specificError) {
      performVerySpecificErrorHandling();
    }
    else {
      // Handle the reason in a general way which is ok for module B functions
    }
  })
  </code></pre></li>
  <li><p>Perform the custom error handling in module A, then after handling the error, throw a fake rejection reason. In module B, add a condition to ignore the fake reason:</p>
  
  <pre><code>.fail(function(reason) {
    if (reason is fakeReason) {
      // Skip handling
    }
    else {
      // Handle the reason in a general way which is ok for module B functions
    }
  })
  </code></pre></li>
  </ol>
  
  <p>Solution 1 requires adding module A specific code to module B.</p>
  
  <p>Solution 2 solves this, but the whole fake rejection approach seems very hackish.</p>
  
  <p>Can you recommend other solutions?</p>