Skip to content

Commit 8b96b2b

Browse files
committed
feat: Handle request errors with attached responses
1 parent 5852ea5 commit 8b96b2b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

request.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,10 @@ Request.prototype.onRequestError = function (error) {
12631263
self.req.end()
12641264
return
12651265
}
1266+
if (error.res && error.res.statusCode && error.res.statusMessage) {
1267+
// Handle the response to populate all the right properties for the consumer to pick up
1268+
self.onRequestResponse.bind(self)(error.res);
1269+
}
12661270
self.clearTimeout()
12671271
self.emit('error', error)
12681272
}

0 commit comments

Comments
 (0)