title: Promises then/catch
body: <p>I have the following code:</p>
  
  <pre><code>return requestAsync({
       method: 'GET',
       url: 'https://' + servers[num - 1] + ':8033/version.txt'
  }).then().catch()
  </code></pre>
  
  <p>I tried throwing an error in the then handler but that didn't work </p>
  
  <p>If a condition is not met in the then handler, I want throw an error that the catch handler handles. How can I get that done?</p>
  
  <p>Code:</p>
  
  <pre><code>var P = require('bluebird');
  var defer = function () {
      var resolve, reject;
      var promise = new P(function () {
          resolve = arguments[0];
          reject = arguments[1];
      });
      return {
          resolve: function () {
              resolve.apply(null, arguments);
              return promise;
          },
          reject: function () {
              reject.apply(null, arguments);
              return promise;
          },
          promise: promise
      };
  };
  
  var pool = {maxSockets: Infinity};
  var requestAsync = function (options) {
      options.pool = pool;
      options.timeout = 60000;
      options.rejectUnauthorized = false;
      options.strictSSL = false;
      var deferred = defer();
      var r = request(options, function (err, res, body) {
          if (err) {
              return deferred.reject(err);
          }
          deferred.resolve(res, body);
      });
  
      deferred.promise.req = r;
  
      return deferred.promise;
  };
  
  return requestAsync({
       method: 'GET',
       url: 'https://' + servers[num - 1] + ':8033/version.txt'
  }).then(function (response) {
       throw new Error('Server is not taken');
  }).catch(function (err) { });
  </code></pre>