Skip to content

Commit

Permalink
Fixes danwrong#59
Browse files Browse the repository at this point in the history
  • Loading branch information
disfated committed Jan 7, 2012
1 parent 39d1dae commit 39b4dc9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/restler.js
Expand Up @@ -127,6 +127,10 @@ mixin(Request.prototype, {
}); });
} }
}, },
_errorHandler: function(err) {
this._respond('error', null, err);
this._respond('complete', null, err);
},
_decode: function(body, response, callback) { _decode: function(body, response, callback) {
var encoder = response.headers['content-encoding']; var encoder = response.headers['content-encoding'];
if (encoder in decoders) { if (encoder in decoders) {
Expand Down Expand Up @@ -165,12 +169,12 @@ mixin(Request.prototype, {
}, },
_makeRequest: function() { _makeRequest: function() {
var self = this; var self = this;

this.request.on('response', function(response) { this.request.on('response', function(response) {
self._responseHandler(response); self._responseHandler(response);
}).on('error', function(err) { }).on('error', function(err) {
self._respond('error', null, err); self._errorHandler(err);
}); });
}, },
run: function() { run: function() {
var self = this; var self = this;
Expand Down

0 comments on commit 39b4dc9

Please sign in to comment.