title: How to dispose resources in rejected promises with bluebird?
body: <p>How can I dispose the serial when the promise is rejected?</p>
  
  <p>The dispose function prints error for rejected promises.</p>
  
  <blockquote>
    <p>Unhandled rejection TypeError: Cannot call method 'isOpen' of
    undefined</p>
  </blockquote>
  
  <pre><code>var pingPort = function(port){
      return new promise(function(resolve, reject){
          var serial = new com.SerialPort(port.comName, {
              baudrate: 19200,
              parser: com.parsers.readline(lineEnd)
          }, false);
          serial.on("data", function(data){
              if (data === responseUuid){
                  resolve(serial);
              }
          });
          serial.open(function(err){
              if (err){
                  //reject(serial)
              }
              else{
                  serial.write(pingUuid + lineEnd);
              }
          });
      });
  };
  
  var dispose = function(port){
      console.log(port.isOpen());
  };
  
  var findPort = function(){
      com.listAsync().map(function(port){
          return pingPort(port).timeout(100).catch(promise.TimeoutError, function(err) {
              console.log("Ping timout: " + port.comName);
              dispose(port);
          }).catch(function(err){
              console.log("Ping error: " + port.comName);
              dispose(port);
          });
      }).each(dispose);
  }();
  </code></pre>