Pass error+body when json requests fail parsing #762

Closed
wants to merge 1 commit into
from
Jump to file
+6 −1
Split
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) {