Permalink
Browse files

Pass error+body when json requests fail parsing

  • Loading branch information...
johan committed Jan 10, 2014
1 parent 2d7072d commit 10a3684c92d2057fdbfae3b387fa8beb41ffb8cb
Showing with 6 additions and 1 deletion.
  1. +6 −1 request.js
View
@@ -884,7 +884,12 @@ Request.prototype.onResponse = function (response) {
if (self._json) {
try {
response.body = JSON.parse(response.body)
- } catch (e) {}
+ } catch (e) {
+ e.body = response.body;
+ self.emit('error', e);
+ debug('JSON.parse error', self.uri.href)
+ return
+ }
}
debug('emitting complete', self.uri.href)
if(response.body == undefined && !self._json) {

0 comments on commit 10a3684

Please sign in to comment.