File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -439,22 +439,25 @@ class Requester extends EventEmitter {
439439 // prepare history from request debug data
440440 var history = getExecutionHistory ( debug ) ,
441441 responseTime ,
442- response ,
443- errorHasUsableResponse = false ;
442+ response ;
444443
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 ) {
444+ if ( err && ! err . res ) {
451445 // bubble up http errors
452446 // @todo - Should we send an empty sdk Response here?
453447 //
454448 // Sending `history` object even in case of error
455449 return onEnd ( err , undefined , history ) ;
456450 }
457451
452+ // If the error has a response attached, use it to populate the response instead of treating
453+ // it as a crash.
454+ if ( err && err . res ) {
455+ res = err . res ;
456+
457+ if ( Buffer . isBuffer ( err . res . body ) ) {
458+ resBody = err . res . body ;
459+ }
460+ }
458461
459462 // Calculate the time taken for us to get the response.
460463 responseTime = Date . now ( ) - startTime ;
You can’t perform that action at this time.
0 commit comments