Skip to content

Commit

Permalink
using addCallback before addErrback
Browse files Browse the repository at this point in the history
due to the way how the add*back methods are implemented in Promise.js,
both the callback and the errback are fired in case of an error if the
errback is specified before the callback
  • Loading branch information
pilif committed Jul 2, 2010
1 parent 124bda7 commit c22d333
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/smtp/client.js
Expand Up @@ -288,17 +288,16 @@ Client.prototype.data = function(data){
var client = this;
var promise = new Promise.Promise();
this.beginData()
.addErrback(function(e){ promise.emitError(e); })
.addCallback(function(){
client.sendData(data)
.addCallback(function(){
client.endData()
.addErrback(function(packet){ promise.emitError(packet); })
.addCallback(function(packet){
promise.emitSuccess();
});
}).addErrback(function(packet){ promise.emitError(packet); });
});
});
}).addErrback(function(e){ promise.emitError(e); })
;
return promise;
};

Expand Down

0 comments on commit c22d333

Please sign in to comment.