Skip to content

Commit d134f73

Browse files
committed
fix: Handle requester errors with attached responses
1 parent 40ef304 commit d134f73

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/requester/requester.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,15 @@ class Requester extends EventEmitter {
439439
// prepare history from request debug data
440440
var history = getExecutionHistory(debug),
441441
responseTime,
442-
response;
442+
response,
443+
errorHasUsableResponse = false;
443444

444-
if (err) {
445+
if (err && err.res && err.res.body && Buffer.isBuffer(err.res.body)) {
446+
errorHasUsableResponse = true;
447+
resBody = err.res.body;
448+
}
449+
450+
if (err && !errorHasUsableResponse) {
445451
// bubble up http errors
446452
// @todo - Should we send an empty sdk Response here?
447453
//

0 commit comments

Comments
 (0)