protected function onRejected(RequestInterface $request, array $options)
    {
        return function ($reason) use ($request, $options) {
            // If was bad response exception, test if we retry based on the response headers
            if ($reason instanceof BadResponseException) {
                if ($this->shouldRetryHttpResponse($options, $reason->getResponse())) {
                    return $this->doRetry($request, $options, $reason->getResponse());
                }
            // If this was a connection exception, test to see if we should retry based on connect timeout rules
            } elseif ($reason instanceof ConnectException) {
                // If was another type of exception, test if we should retry based on timeout rules
                if ($this->shouldRetryConnectException($reason, $options)) {
                    return $this->doRetry($request, $options);
                }
            }

            // If made it here, then we have decided not to retry the request
            return \GuzzleHttp\Promise\rejection_for($reason);
        };
    }
protected function onRejected(RequestInterface $request, array $options)
    {
        return function ($reason) use ($request, $options) {
            // If was bad response exception, test if we retry based on the response headers
            if ($reason instanceof BadResponseException) {
                if ($this->shouldRetryHttpResponse($options, $reason->getResponse())) {
                    return $this->doRetry($request, $options, $reason->getResponse());
                }
            // If this was a connection exception, test to see if we should retry based on connect timeout rules
            } elseif ($reason instanceof ConnectException) {
                // If was another type of exception, test if we should retry based on timeout rules
                if ($this->shouldRetryConnectException($reason, $options)) {
                    return $this->doRetry($request, $options);
                }
            }

            // If made it here, then we have decided not to retry the request
            return \GuzzleHttp\Promise\rejection_for($reason);
        };
    }
protected function onRejected ( RequestInterface $ request , array $ options ) { return function ( $ reason ) use ( $ request , $ options ) { // If was bad response exception, test if we retry based on the response headers if ( $ reason instanceof BadResponseException ) { if ( $ this -> shouldRetryHttpResponse ( $ options , $ reason -> getResponse ( ) ) ) { return $ this -> doRetry ( $ request , $ options , $ reason -> getResponse ( ) ) ; } // If this was a connection exception, test to see if we should retry based on connect timeout rules } elseif ( $ reason instanceof ConnectException ) { // If was another type of exception, test if we should retry based on timeout rules if ( $ this -> shouldRetryConnectException ( $ reason , $ options ) ) { return $ this -> doRetry ( $ request , $ options ) ; } } // If made it here, then we have decided not to retry the request return \ GuzzleHttp \ Promise \ rejection_for ( $ reason ) ; } ; }
An exception or error was thrown during processing

If the reason is a BadResponseException exception, check to see if
the request can be retried.  Otherwise, pass it on.

@param RequestInterface $request
@param array $options
@return callable
An exception or error was thrown during processing